How to get today date in SANDBOX using client script? I tried the below things but

DINESH CHINNAD1
Giga Expert

Hi,

 

I am new to Servicenow


var today=new Date(); //by using these gives output as UTC form date and time, so i am unable to macth this date with my input whatever i gave in the form

 

var a= now();

var b=nowDateTime();

var right_now=g_form_Date_Time;

 

and also i tried Glide System, Ajax and some other things . Glide System(gs) and Current does not supported by SANDBOX...

 

and tried few more things but i am not able to find???

 

My question is i want to accept the Date of Birth of a person with past and present date only (current date) it will not accept the future date.....

 

Can anyone Guide me....

 

Thanks in Advance...

10 REPLIES 10

Mike Allen
Mega Sage

var today = new GlideDateTime();


var dob = g_form.getValue('date_of_birth');


if (dob > today)){


g_form.showErrorBox("date_of_birth", "You are not allowed to have a date of birth blah blah blah");


}


Hello Mike Allen,



Rightnow i am practicing in SANDBOX.. it will not support GlideDateTime... Already tired this one... i checked with Alert, Its not working..



Thanks



Anyother way?????


What if you add a today.addHours to your script to simulate the right time zone?


Are you using in client script or business rule. Alert will not work in business rule, for BR please gs.log starement and check log table.




Sent via the Samsung GALAXY S ® 5, an AT&T 4G LTE smartphone