Posted By

qrist0ph on 05/13/08


Tagged

date format


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

taboularasa


Format Date


 / Published in: Python
 

  1. import datetime
  2. now = datetime.datetime.now()
  3. print now.strftime("%Y%m%dT%H%M%S")
  4.  
  5. # >> 20030805T213611
  6.  
  7. d = datetime.datetime.now() + datetime.timedelta(days=3)
  8. d. strftime('%Y-%m-%d')
  9. # >> '2009-04-01'
  10.  
  11. now = datetime.datetime(*time.strptime("16/6/1981", "%d/%m/%Y")[0:5])

Report this snippet  

You need to login to post a comment.