- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 12:25 AM
Hi, I wrote a script, and I used GlideDateTime to print out the date(start_date) and the month of the date, but the output is different on the first day of each month. Could you tell me why?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 02:59 AM
Hi Jieun,
Probably because it's using JVM timezone. As written in the document, use getMonthUTC() instead.
str = '2021-02-01 00:00:10';
var gdt = new GlideDateTime();
//gdt.setDisplayValue(str);
gdt.setValue(str);
gs.print('gdt:' + gdt);
gs.print('getValue:' + gdt.getValue());
gs.print('getDisplayValue:' + gdt.getDisplayValue());
gs.print('getMonth:' + gdt.getMonth());
gs.print('gdtMonthLocalTime:' + gdt.getMonthLocalTime());
gs.print('gdtMonthUTC:' + gdt.getMonthUTC());
Execution result:
*** Script: gdt:2021-02-01 00:00:10
*** Script: getValue:2021-02-01 00:00:10
*** Script: getDisplayValue:2021-02-01 09:00:10
*** Script: getMonth:1
*** Script: gdtMonthLocalTime:2
*** Script: gdtMonthUTC:2
getMonth()
Use getMonthLocalTime() and getMonthUTC() instead of this method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 12:47 AM
Hi,
getMonth() will give you the month number not month name.
Kindly mark helpful/correct if my I answered your query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 01:15 AM
Hi
You can try something like this, it would definitely help:
var gd = new GlideDate();
gs.print(gd.getByFormat("MMMM"));
Output :-
10:48:40.861: April |
or if you want the Name and Day of Month
Incoming Format: new GlideDateTime();
Simple Format: EEEE dd MMMMM
var gDate = new GlideDateTime().getDate();
gs.print(gDate.getByFormat('EEEE dd MMMMM'));
Thursday 14 December
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2022 02:59 AM
Hi Jieun,
Probably because it's using JVM timezone. As written in the document, use getMonthUTC() instead.
str = '2021-02-01 00:00:10';
var gdt = new GlideDateTime();
//gdt.setDisplayValue(str);
gdt.setValue(str);
gs.print('gdt:' + gdt);
gs.print('getValue:' + gdt.getValue());
gs.print('getDisplayValue:' + gdt.getDisplayValue());
gs.print('getMonth:' + gdt.getMonth());
gs.print('gdtMonthLocalTime:' + gdt.getMonthLocalTime());
gs.print('gdtMonthUTC:' + gdt.getMonthUTC());
Execution result:
*** Script: gdt:2021-02-01 00:00:10
*** Script: getValue:2021-02-01 00:00:10
*** Script: getDisplayValue:2021-02-01 09:00:10
*** Script: getMonth:1
*** Script: gdtMonthLocalTime:2
*** Script: gdtMonthUTC:2
getMonth()
Use getMonthLocalTime() and getMonthUTC() instead of this method.