I need to have the date.
The format of the time should be 2017-01-18T07:34:35Z
I have tried this but it does not work:
import datetime
i = datetime.datetime.now()
date = %i.year "-" %i.month "-" %i.day "T" %i.hour ":" %i.minute ":" %i.second "Z"
I need to have the date.
The format of the time should be 2017-01-18T07:34:35Z
I have tried this but it does not work:
import datetime
i = datetime.datetime.now()
date = %i.year "-" %i.month "-" %i.day "T" %i.hour ":" %i.minute ":" %i.second "Z"
from time import gmtime, strftime
strftime("%a, %d %b %Y %H:%M:%S", gmtime())
# Will output
'Thu, 03 May 2017 16:21:01'
for your example use:
from time import gmtime, strftime
strftime("%y-%d-%mT%H:%M:%SZ", gmtime())
2017-03-05T07:34:35Z
import time
now = time.strftime("%c")
see more in https://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/