$jsapi.currentTime
This method returns the current Unix time in the UTC time zone.
Syntax
The method is called without arguments and returns a number in milliseconds.
$jsapi.currentTime(); // => 1687505400000
Usage details
-
Since
$jsapi.currentTime
always returns a UTC timestamp, it cannot be used to retrieve the current time relevant for users: they are most likely located in different time zones.tipUse the$jsapi.timeForZone
method to retrieve the current time adjusted by the time zone. -
If your project uses
$jsapi.currentTime
and has automated tests, you need to override the time the tests will treat as their current time. Use the<dateTime>
tag to do this.
How to use
# Here, we import the Moment.js library from the zb-common system project.
require: dateTime/moment.min.js
module = sys.zb-common
theme: /
state: CurrentSystemTime
q!: * (what time is it/what ('s/is) the time) *
script:
var timestamp = $jsapi.currentTime();
$temp.time = moment(timestamp).format("h.m a");
a: By my watch, it’s {{$temp.time}}.