Subscribe
Accepted Solution

OnCommand API Services - Convert timestamp to date/time

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
 

Re: OnCommand API Services - Convert timestamp to date/time

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.

Re: OnCommand API Services - Convert timestamp to date/time

Awesome my friend !!!!

 

It works !  Smiley LOL