Select to view content in your preferred language

Converting esriFieldTypeDate numeric value to a proper DateTime value

3333
2
Jump to solution
03-07-2013 06:08 PM
SanthoshKumar3
Emerging Contributor
ArcGIS REST service is returning the value of a date column  as 1185840000000.

Can anyone tell me how in this world that can be converted to a proper date time in C#?
0 Kudos
1 Solution

Accepted Solutions
RahulMetangale1
Frequent Contributor
sansan,

The date value you mentioned is epoch time,which is defined as the number of seconds since midnight (UTC) on 1st January 1970.
public DateTime FromUnixTime(long unixTime) {     var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);     return epoch.AddSeconds(unixTime); }

View solution in original post

0 Kudos
2 Replies
RahulMetangale1
Frequent Contributor
sansan,

The date value you mentioned is epoch time,which is defined as the number of seconds since midnight (UTC) on 1st January 1970.
public DateTime FromUnixTime(long unixTime) {     var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);     return epoch.AddSeconds(unixTime); }
0 Kudos
SanthoshKumar3
Emerging Contributor
Rahul,

Thanks for the explanation.
I just changed the AddSeconds to AddMilliSeconds and it worked like charm.

-Santhosh
0 Kudos