fork download
  1.  
  2. import datetime
  3. d = datetime.datetime.today()
  4.  
  5. print(d)
  6. print(d.strftime('%Y'))
  7. print(d.strftime('%Y/%m'))
  8. print(d.strftime('%Y/%m/%d'))
  9. print(d.strftime('%Y/%m/%d %H'))
  10. print(d.strftime('%Y/%m/%d %H:%M'))
  11. print(d.strftime('%Y/%m/%d %H:%M:%S'))
  12.  
  13. print()
  14.  
  15. print(datetime.datetime.today())
  16. print(datetime.datetime.today().strftime('%Y'))
  17. print(datetime.datetime.today().strftime('%Y/%m'))
  18. print(datetime.datetime.today().strftime('%Y/%m/%d'))
  19. print(datetime.datetime.today().strftime('%Y/%m/%d %H'))
  20. print(datetime.datetime.today().strftime('%Y/%m/%d %H:%M'))
  21. print(datetime.datetime.today().strftime('%Y/%m/%d %H:%M:%S'))
  22.  
  23.  
Success #stdin #stdout 0.02s 27976KB
stdin
Standard input is empty
stdout
2017-08-15 23:28:36.673581
2017
2017/08
2017/08/15
2017/08/15 23
2017/08/15 23:28
2017/08/15 23:28:36

2017-08-15 23:28:36.673646
2017
2017/08
2017/08/15
2017/08/15 23
2017/08/15 23:28
2017/08/15 23:28:36