Help Parsing JSON Dates
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I am struggling to convert created_at and end_time to an actual date. This data was originally in json format but was able to parse out the majority of the data except for the dates. The date fields originally came in vstring format and I cannot seem to find a way to actually make it a date. Any insight would be greatly appreciated. I can include a copy of the workflow, if needed!
Thanks,
Michael
Solved! Go to Solution.
- Labels:
- API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Would be you able to get the original format?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The time fields are in EPOCH time. This is number of seconds since 1970-01-01.
Apply this on those fields:
DATETIMEADD('1970-01-01 00:00:00',[created_at],'seconds')
I’m not on my computer so give the formula a shot and let me know!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
After some research on the internet, I think this format of time is called Epoch & Unix Timestamp.
https://www.epochconverter.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Happy to help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
wonderful Explanation and it is really helpful.
Was wondering how json can be converted to normal dates and you just gave not only date but even minutes , seconds too.
Kudos to you!
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
JSON does not know anything about dates. What .NET does is a non-standard hack/extension. The problem with dates in JSON and really JavaScript in general – is that there's no equivalent literal representation for dates. In JavaScript following Date constructor straight away converts the milliseconds since 1970 to Date as follows:
var jsonDate = new Date(1297246301973);
Then let's convert it to js format:
var date = new Date(parseInt(jsonDate.substr(6)));
The substr() function takes out the /Date( part, and the parseInt() function gets the integer and ignores the )/ at the end. The resulting number is passed into the Date constructor .
