0

I have the following python time value in JSON format...any inputs on how to convert it to to regular time format

u'lastUpdated': 1358294533

1 Answer 1

2

datetime.fromtimestamp from the datetime module should do it.

For example:

>>> from datetime import datetime
>>> d = datetime.fromtimestamp(1358294533)
>>> d.isoformat()
'2013-01-15T19:02:13'

For getting a more controlled string representation of the datetime use the datetime.strftime function.

Sign up to request clarification or add additional context in comments.

2 Comments

@user2639990 Yes (hence the answer). Without more details we might have different definitions of what 'regular time format' means. I think it means getting a datetime object.
@user2639990 You can put it in whatever format you like.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.