Potentially useful code snippets
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
287 B

2 years ago
# Python time conversions
x = datetime.datetime.now()
x.strftime('%Y-%m-%d %H:%M:%S')
'2021-11-30 08:11:51'
String to datetime: datetime.strptime
z=datetime.strptime(y, '%Y-%m-%d %H:%M:%S') #python 3.8 + dammit
datetime.datetime(*(time.strptime(y, '%Y-%m-%d %H:%M:%S')[0:6]))#painful