- 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 05:12 AM
It looks like you need to specify a format:
Try
gs.info(time.getByFormat('hh:mm:ss'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 05:25 AM
Hi @String
Try below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2023 05:33 AM
@String ,
Please try below method:
var gdt= new GlideDateTime();
gs.info(gdt.getDisplayValueInternal());
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- 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: