type
status
date
slug
summary
tags
category
icon
password
每个时间戳都以自从格林威治时间1970年01月01日00时00分00秒起经过了多长时间来表示
💡
注: 以下代码在Python3下运行通过, Python2下未经测试。

基本方法

格式化符号

python中时间日期格式化符号:

常用用法

将字符串的时间转换为时间戳

方法:
结果:

时间戳转换为指定格式日期

方法:
结果:

格式切换

把-分割格式2017-11-24 17:30:00 转换为斜杠分割格式: 结果:2017/11/24 17:30:00
方法:
结果:

获取当前时间并转换为指定日期格式

方法:
结果:

获得三天前的时间的方法

方法:
结果:
注:timedelta()的参数有:days,hours,seconds,microseconds

使用datetime模块来获取当前的日期和时间

Linux中date命令用法人生工具
Loading...