How to find today day in serverside scripting?

keerthilatha
Tera Expert

Hi Team,

How can we find out day in server side scripting.For example, in 2016-12-13, I want to print '13'. Is there any functions to get the day.

Thanks & Regards,

Keerthi

1 ACCEPTED SOLUTION

Just 2 lines will print the day of month: var gdt = new GlideDateTime(); gs.print(gdt.getDayOfMonth());


View solution in original post

5 REPLIES 5

david_legrand
Kilo Sage

Hi Keerthi, the last Friday Challenge was about it if you want to see some examples


Friday Challenge - 18 - Birthday and un-birthday



Of course, it'll be the "GlideDateTime" API which will give you the necessary functions to succeed


https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_APIRef.dita


amaradiswamy
Kilo Sage

Hi Keerthi,



You can use gs.now() or GlideDate() methods to get the todays date and then by using substring method you can get the required number(year,month,date,day).


GlideDate and GlideDateTime examples


http://wiki.servicenow.com/?title=GlideDateTime



Thanks and regards


Swamy


Just 2 lines will print the day of month: var gdt = new GlideDateTime(); gs.print(gdt.getDayOfMonth());


Hello @anurag92 

using your script i am getting backend value like 21 but i want to print day name like monday .

can we print day name if is it possible please guide me on this.

Thank You.