GlideDateTime is the one of the class which will be providing the value of the Date and time.
Example what is the today’s date what is the current time and many more.
The GlideDateTime is specifically for the Date and Time Value you can simply able to achieve the same through the Glide API as well but then the ServiceNow best practice is saying for the Date and Time values, formatting , conversion user the GlideDateTime class. We will see the few methods of that class as below
GlideDateTime()–
For creation of the object of the GlideDateTime class you may do the something as below –
var gd_datetime =new GlideDateTime();
GlideDateTime(Parameter) –
Here the parameter is containing the value of the date time, means if you want to make the some value as the default in the parameter orr you want to pass some date time in the parameter then you may use this method
var start=new GlideDateTime(‘2022-02-02 12:00:00’);
var end =new GlideDateTime(start);
gs.info(end);
add(Parameter) –
If you want to add the any specific Date Time Value to the object then you may use this method
var gtDateTtime=new glideDateTime(‘2022-02-02 12:00:00′);
var gtTime=new GlideTime();
gtTime.setValue(’00:00:30’);
gtDateTime.add(gtTime);
Kind of there are multiple methods for the checking the before date, add seconds and many more
You may check the official document for the same
getDate() –
This is the one of the method which will return you your stored date
You may also go and set the value for the date and time as per the requirement or you may validate the date is in the correct format or not.
This all methods are available in the GlideDateTime class