How to get current date time as default value in datetime field on Modal page?

Sai Kumar
ServiceNow Employee
ServiceNow Employee

We have a startTime(Date-Time) component on a modal page. The requirement is to set the current date time as the default value when the modal page opens. The user should be allowed to make changes to that startTime field.

2 REPLIES 2

shyamkumar VK
Kilo Patron

@Sai Kumar  , Something like this

 

<g:ui_date_time name="end_date" id="end_date" value='${gs.nowDateTime()}'

 

Regards,

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Hugo Barros
Tera Contributor

hey @Sai Kumar, are you using a widget?

if so, maybe you can declare data.currentDate = new GlideDateTime(); in your server side code.

then you cal call it from html with something like:

<input style="margin-bottom: 25px;" id="typeYourID" class="typeYourClass" type="date" >{{data.currentDate}}</input > 

No needing to be exactly like this, just giving an example.
have a nice day!