Import the datetiem class of the datetime module and assign the result of the today () function to the variable t
from datetime import datetime
t = datetime.today
t
Then
datetime.datetime(2020, 3, 12, 23, 37, 45, 238787)
Becomes
str_t = t.strftime('%Y year%m month%d day/%H o'clock%M minutes%S seconds')
str_t
Then
'March 12, 2020/23:37:45'
Becomes
time_t = datetime.strptime(str_t, '%Y year%m month%d day/%H o'clock%M minutes%S seconds')
time_t
Then
datetime.datetime(2020, 3, 12, 23, 37, 45)
Will be.
Recommended Posts