3

I got a .Net Date Object back from my get request that looks like this

/Date(1503528300000-0500)/

I see this post Date conversion .NET JSON to ISO about how to convert it to ISO. but how about Python dateTime (not php)? Ultimately I want to use datetime.datetime.now() to compare with the converted datetime and get the difference.

and can someone please explain what is the part after the -? in this case what is the 0500?

J.Doe
  • 179
  • 6
  • Possible duplicate of [PHP date format /Date(1365004652303-0500)/](https://stackoverflow.com/questions/16749778/php-date-format-date1365004652303-0500) – gilliduck Aug 24 '17 at 01:32
  • My inquiry clearly states Python not PHP – J.Doe Aug 24 '17 at 01:34
  • Core concept is the same – gilliduck Aug 24 '17 at 01:34
  • The 0500 appears to be the offset from UTC. Depending on DST, that could be Eastern or Central for North America. – afilbert Aug 24 '17 at 01:35
  • Possible duplicate of [How does one convert a .NET tick to a python datetime?](https://stackoverflow.com/questions/3875806/how-does-one-convert-a-net-tick-to-a-python-datetime) – Jose Dzireh Chong Aug 24 '17 at 01:37
  • @gillduck maybe it answers what components of .net object are. but it didn't explain how to do what I desires in python. so it didn't fully answer my question. – J.Doe Aug 24 '17 at 01:37
  • @JoseDzirehChong the .NET tick does not have the offset portion from UTC. It is not the same – J.Doe Aug 24 '17 at 01:38
  • @afilbert Thank you for the comment that is very helpful. Can you elaborate more on how the offset works? – J.Doe Aug 24 '17 at 01:39
  • If you know how to get the ISO with offset, then this may help on the python end: https://stackoverflow.com/a/3908349/119041 – afilbert Aug 24 '17 at 01:39
  • 1
    @J.Doe for sure. The offset is just the number of hours from "zulu" time, or UTC. The Z in an ISO 8601 date/time indicates Zulu time. You want to be careful with offsets, however, and double check whether they're standard or DST (daylight savings time). I recommend storing in UTC ALWAYS, then present according to local offset at the time (again, changes with DST). – afilbert Aug 24 '17 at 01:42

0 Answers0