Possible Duplicate:
Converting unix timestamp string to readable date in Python
When I do time.time() I get something like: 1342648659.223746. How can I convert it to unix time that looks like this: 2012-07-18T21:42:00Z?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Python’s standard datetime module is quite handy for all kinds of date/time manipulation.
For your particular problem, the
isoformat()method is handy. For example, if you already have a time in seconds since the Epoch (such as your1342648659.223746):And if you just want the current (UTC) time, ISO formatted:
If you absolutely require the timezone information in your output (i.e. the
Zfor UTC in your example), you’ll either have to append it manually, or fall back to usingstrftime: