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