The CreatorCon Call for Content is officially open! Get started here.

Current time in numeric value

poornima2
Mega Expert

Is it possible to get the current time(only the time) in numeric value?Thanks

4 REPLIES 4

Jay_Ford
Kilo Guru


var theTime = nowDateTime().toString().split(' ')[1];


This would return the current time in hh:mm:ss format. Is that what you are looking for?


Ivan Martez
ServiceNow Employee
ServiceNow Employee

If you need to convert a date and time to a numeric value. You need to use the following.



current.my_date_field.getGlideObject().getNumericValue();


This will convert to a numeric value not just a string. Here is a wiki article that compares 2 date fields
http://wiki.service-now.com/index.php?title=Compare_Two_Date_Fields


Not applicable



var today = new GlideDateTime();
gs.print(today.getTime().getNumericValue()/1000); // time, in seconds


is probably what you're after.


poornima2
Mega Expert

Thanks everyone and James gave the exact script what i was looking for.