datetime - Python - Convert timestamp including timezone (+0200) to humanly readable -


this question has answer here:

i can't life of me figure out how convert timestamp on form 1433140740000+0200 datetime object or humanly readable representation. also, format specifically? i'm assuming +0200 represents timezone.

i can seem find questions regarding timestamps without timezones, such this answer, int("1433140740000+0200") give me error. appreciated. thanks!

edit: mentioned in comment, further examination of api getting these values reveals other timestamps different values thought represent timezones. e.g: 315529200000+0100. entire line of data looks this: "arrivaltime": "/date(1433051640000+0200)/", , full response can found here.

second edit: far can tell, timestamps unix timestamps, they're given in milliseconds (hence trailing zeros), , +0200 indicates timezone utc+02:00. now, i'll trim out zeros , timezone, , convert shown in linked question, before adding timezone manually afterwards. timestamps +0100 remain mystery me, i've found they're same date, 1/1/1980 12:00am. have different identifier: actualtime, opposed arrivaltime on others. anyway, guys!

you can use string split remove timezone

import datetime intstring = int( ('1433140740000+0200').split('+')[0])  print( datetime.datetime.fromtimestamp(intstring/1000).strftime('%y-%m-%d %h:%m:%s') ) 

i had change make work

intstring /1000


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -