Python tips

lun. 04 octobre 2010 by Martin Deudon

Datetime

Get the current date/time and format it (e.g. to create a filename) :

import datetime
print(datetime.datetime.now().strftime('%d%b%Y-%Hh%M'))
>> '10Oct2018-18h01'

See Comportement de strftime() et strptime() for the availables directives