I have a 24-character string and want to get the tuple.
E.g.:
'Fri Apr 25 12:24:47 2014'
(via time.ctime(time.time())
)
Return Value The asctime() function returns a pointer to the resulting character string.
Description. The asctime() function converts time, stored as a structure pointed to by time, to a character string. You can obtain the time value from a call to the gmtime() , gmtime64() , localtime() , or localtime64() function.
time.strptime()
parses strings into time tuples again; the default parse format matches the output of time.ctime()
and time.asctime()
:
>>> import time
>>> time.ctime(time.time())
'Fri Apr 25 12:12:06 2014'
>>> time.strptime(time.ctime(time.time()))
time.struct_time(tm_year=2014, tm_mon=4, tm_mday=25, tm_hour=12, tm_min=12, tm_sec=10, tm_wday=4, tm_yday=115, tm_isdst=-1)
>>> time.strptime(time.asctime())
time.struct_time(tm_year=2014, tm_mon=4, tm_mday=25, tm_hour=12, tm_min=13, tm_sec=6, tm_wday=4, tm_yday=115, tm_isdst=-1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With