- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 05:07 AM
Hi team ,
am using the below code to get the date and time
var gdt = new GlideDateTime();
var date = gdt.getDate();
var time = gdt.getTime();
gs.info(date+"T"+time);
output:
2023-02-27T1970-01-01 13:06:26
but am getting 1970-01-01 ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 05:33 AM
Hi,
If you need date and time you can use this
var gdt = new GlideDateTime();
gs.info(gdt.getDisplayValue()); //Return the date time in the logged in user time zone
If you need date time in specific format, please use the below script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 06:00 AM
Hi @String ,
Use below code to get time the way you wanted
Output:
*** Script: 2023-02-27 13:57:19
*** Script: 13:57:19