strftime()函数可以把YYYY-MM-DD HH:MM:SS格式的日期字符串转换成其它形式的字符串。
举例用法:当前时间:2020-07-15 14:35:33.345
- strftime('%d',getdate()) --结果:07-15
- strftime('%f',getdate()) --结果:33.345 --小数形式的秒
- strftime('%H',getdate()) --结果:14
- strftime('%m',getdate()) --结果:07
- strftime('%M',getdate()) --结果:35
- strftime('%S',getdate()) --结果:33
- strftime('%w',getdate()) --结果:3 --周三(数值范围【0~6】,表示周日到周六)
- strftime('%j',getdate()) --结果:196 --数值范围【0~366】算出某一天是该年的第几天
- strftime('%Y',getdate()) --结果:2020
- 更好的用法:strftime('%Y-%m',getdate()) --结果:2020-07