Software Development Kit (SDK) and API Discussions

OnCommand API Services - Convert timestamp to date/time

calori
2,804 Views

Hi All,

 

I am trying to convert the timestamp from API Services output to date/time format, but I for some reason I cannot get a date/time format.

I tried to convert using python and I received a message that the year is out of range

 

Follow below an example code:

import datetime

your_timestamp = 1460409856461

print datetime.datetime.fromtimestamp(your_timestamp)

The output is:

ValueError: year is out of range
 

1 ACCEPTED SOLUTION

asulliva
2,792 Views

It might be in milliseconds, try dividing by 1000 (and rounding down to the nearest whole number).

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

View solution in original post

2 REPLIES 2

asulliva
2,793 Views

It might be in milliseconds, try dividing by 1000 (and rounding down to the nearest whole number).

 

Andrew

If this post resolved your issue, please help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

calori
2,788 Views

Awesome my friend !!!!

 

It works !  Smiley LOL

Public