How to get today date in SANDBOX using client script? I tried the below things but
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2014 11:57 AM
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...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2014 02:29 AM
Hi Dinesh,
Write this below script onchange of DOB field.
function onChange(control, oldValue, newValue, isLoading)
{
if(isLoading)
{
return;
}
var ga = new GlideAjax('includescriptname');
ga.addParam('sysparm_name','dateFunction');
ga.addParam('dob_date', newValue);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
if(answer>=0)
{
return true;
}
else
{
alert("please enter valid DOB");
return false;
}
}
}
Writhe this code in includescript
_____________________________
var selectingdate = this.getParameter('dob_date');
var currentdate=gs.now();
var answer = gs.dateDiff(currentdate,selectingdate,true);
return answer;