- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 09:39 AM
I need to extract the current date-time in the below format -
yyyy-mm-dd hh:mm:ss.ms
i.e I require milliseconds also to be displayed along with hours/minutes/seconds.
e.g. Expected data-time = 2022-05-27 10:00:20.248
Please suggest the approach to get it.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 08:52 PM
Below code gives me the correct answer -
var d = new GlideDateTime()
var ms = d.getNumericValue();
var dateTimeTillMs = new Date(ms).toISOString();
gs.info(dateTimeTillMs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 09:57 AM
Hi Mahesh,
Can you try this
var gdt = new GlideDuration(urdatefield);
var value = gdt.getByFormat('HH:mm:ss ms');
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 08:49 PM
This is not giving the correct answer. ms returns the minute and second in single digit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 08:52 PM