To get time from glide date time

joshishree
Kilo Contributor

I am not getting the time field from the below code as i have to set it to 08:00:00 how should i do it. next day date i am getting properly how to get the time.And then return the complete date and set the field in client script.

find_real_file.png

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Bhagyashree,



Can you explain your requirement in details



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

joshishree
Kilo Contributor

In planned start date of project form I have to populate a date on on load where the date is the next date like if today is 22 it should be 23.and the time should be set as "08:00:00"


Hi Bhagyashree,



In your script include function have following script:



var gdt = new GlideDateTime();


gdt.addDaysUTC(1);


return gdt.getDate();



then in client script add 08:00:00 to the answer which you get from GlideAjax


g_form.setValue('closed_date', answer + "08:00:00");



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Here is an example:


var myDate = new GlideDateTime();




var myarr = String(myDate.getDisplayValueInternal().toString());




myarr = myarr.split(' ');




for (var i = 0; i < myarr.length; i++) {


  gs.print(myarr[i]);


}



In background scripts:



[0:00:00.003] Script completed in scope global: script


*** Script: 2017-06-22


*** Script: 05:42:00