- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 10:56 PM
Hello,
I am trying to convert date format retrieved from API to Glide Date/Time format
API Date - 1520577092413
Has anyone done that before ?
Thank you,
Eash
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 11:03 PM
Hello,
Yes, the code is a lot simpler than first suggested:
var epochString = "1520577092413";
var gdt = new GlideDateTime();
gdt.setNumericValue(epochString);
gdt.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 11:03 PM
Hello,
Yes, the code is a lot simpler than first suggested:
var epochString = "1520577092413";
var gdt = new GlideDateTime();
gdt.setNumericValue(epochString);
gdt.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 11:09 PM
Hi Eashwar
You should be able to use the
GlideDateTime mehtod.
// Capture the milliseconds from the API you mentioned
var ms = '1520577092413';
// Create a GlideDateTime object
var gdt = new GlideDateTime();
gdt.subtract(gdt.getNumericValue()); // Resets the date to 0 so that we can add the milliseconds to the date
gdt.add(ms); // Adds the milliseconds to the date
var date = gdt.getDisplayValue(); // date should now contain the display value.
var numDate = gdt.getNumericValue(); // numDate should now contain the numeric value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2018 10:43 AM
Thank you guys