963 shaares
3 results
tagged
date
All about time and weather
Sérialiser une date pour avoir: année, mois, jour, heure, minute, seconde, microseconde :
import datetime
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
>>> '2012-07-22 16:19:00.539570'
A l’inverse, parser une date:
datetime.datetime.strptime('2012-07-22 16:19:00.539570', '%Y-%m-%d %H:%M:%S.%f')
>>> datetime.datetime(2012, 7, 22, 16, 19, 0, 539570)
import datetime
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
>>> '2012-07-22 16:19:00.539570'
A l’inverse, parser une date:
datetime.datetime.strptime('2012-07-22 16:19:00.539570', '%Y-%m-%d %H:%M:%S.%f')
>>> datetime.datetime(2012, 7, 22, 16, 19, 0, 539570)
Dateutils are a bunch of tools that revolve around fiddling with dates and times in the command line with a strong focus on use cases that arise when dealing with large amounts of financial data.