title: DATE::NOW section: 1g version: 1.0.0 date: 2023 author: laplante@plcb.ca
date::now Return the current time and date.
date::now or now([location: string, error: variable])
Returns the current time and date.
An optional location
can be specified to get the time in a specific timezone.
Specifies the timezone for the returned date/time.
On Linux, available locations can be listed with:
awk '/^Z/ { print $2 }; /^L/ { print $3 }' /usr/share/zoneinfo/tzdata.zi
The output includes a list of valid timezone identifiers (e.g., America/Montreal
, Europe/Paris
, Asia/Tokyo
).
res={{ t := now(); t; }}.
→ res=2023-10-23 16:54:53.074186 +0200 CEST m=+0.009438501.
res={{ t1 := now(); sleep("5s"); t2 := now(); t2-t1; }}.
→ res=5.001040792.+.
res={{ t1 := now(); jt1 := time_json(t1); t2 := t1-"1h"; jt2 := time_json(t2); jt1.hour-jt2.hour; }}.
→ res=1.
res={{
t := date::now(error:err, location:"montreal");
err; "-";
t;
t := date::now(error:err, location:"America/Montreal");
err; "-";
t;
}}.
→ res=time::now : invalid location montreal : unknown time zone montreal--2023-10-23 10:56:11.760428 -0400 EDT.
laplante@plcb.ca