Convert Time Type Field into Seconds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 02:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 02:47 AM
Hi,
So what script did you use?
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 02:52 AM
Hi Ankur ,
I am using below script but its giving incorrect value .
Also , new GlideDateTime(current.u_abc) is giving : some other time 18:00:00 . not the current time on form (10:00:00)
var time = new GlideDateTime(current.u_abc).getNumericValue()/1000;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 06:54 AM
Hello Roshni,
Could you please check with below script:
The time in seconds should be correct. You can once check with .getDisplayValue() method and it should give the datetime present on form.
if you directly check the time like gs.print(gdt) then the time is return in GMT timezone I think and gdt.getDisplayValue() or new GlideDateTime(current.getValue("u_abc")).getDisplayValue() will return time in timezone set by user on the instance.
var gdt = new GlideDateTime(current.getValue("u_abc"));
var time = gdt.getNumericValue() / 1000;
gs.print(gdt.getValue());
gs.print(gdt.getDisplayValue());
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 11:10 PM
Hello Roshni,
Just wanted to check with you, if the above response answered your question. If yes, then please do close this thread/question by marking the appropriate response as correct.
If you still need any further help or guidance on this then please update those on this question.
Thanks