datetime()
datetime() → object
Returns the current date and time as an object, including the unix epoch.
Returns the device real-time clock as an object. valid indicates whether the
clock has been set. Set the timezone with setEnv("sys.utc_offset", hours).
Available properties: valid, uptime, epoch, year, month, monthDay,
weekDay, hour, minute, second.
Returns
object
e.g. {"valid":true,"uptime":1437.05,"epoch":1589247811,"year":2020,"month":5,"monthDay":12,"weekDay":2,"hour":1,"minute":43,"second":31}
Example
print(string(datetime()));
let ts = datetime().epoch; // unix timestamp
let year = datetime().year; // e.g. 2020