You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,7 @@ WebScreen exposes a comprehensive set of functions to JavaScript applications ru
22
22
"display": {
23
23
"brightness": 200
24
24
},
25
+
"timezone": "EST5EDT,M3.2.0,M11.1.0",
25
26
"script": "my_app.js"
26
27
}
27
28
```
@@ -86,6 +87,56 @@ The following functions are available in your JavaScript applications:
86
87
-**wifi_get_ip()**
87
88
Returns the local IP address as a string.
88
89
90
+
### NTP Time Functions
91
+
92
+
Time is automatically synchronized via NTP when the device connects to WiFi. The timezone is configured in `webscreen.json` using a POSIX TZ string (see the WebScreen Admin tool for a full dropdown of all timezones).
93
+
94
+
-**ntp_synced()**
95
+
Returns `true` if NTP time has been synchronized, `false` otherwise. Always check this before using other time functions.
96
+
```javascript
97
+
if (ntp_synced()) {
98
+
print("Time is available");
99
+
}
100
+
```
101
+
102
+
-**get_hours()**
103
+
Returns the current hour (0-23) in the configured timezone, or -1 if NTP is not synced.
104
+
105
+
-**get_minutes()**
106
+
Returns the current minute (0-59), or -1 if NTP is not synced.
107
+
108
+
-**get_seconds()**
109
+
Returns the current second (0-59), or -1 if NTP is not synced.
110
+
111
+
-**get_year()**
112
+
Returns the current year (e.g. 2026), or -1 if NTP is not synced.
113
+
114
+
-**get_month()**
115
+
Returns the current month (1-12), or -1 if NTP is not synced.
116
+
117
+
-**get_day()**
118
+
Returns the current day of the month (1-31), or -1 if NTP is not synced.
119
+
120
+
-**get_weekday()**
121
+
Returns the day of the week (0=Sunday, 6=Saturday), or -1 if NTP is not synced.
122
+
123
+
-**get_epoch()**
124
+
Returns the current Unix timestamp in seconds, or -1 if time is not valid (before 2021).
/settime <epoch> [tz] - Set device time from epoch
64
66
/monitor [cpu|mem|net] - Live system monitoring
65
67
/reboot - Restart the device
66
68
@@ -368,6 +370,60 @@ Live Monitor - Press any key to stop
368
370
- Debug WiFi connectivity issues
369
371
- Performance profiling during development
370
372
373
+
### Time Commands
374
+
375
+
#### `/time`
376
+
Displays the current device time, epoch timestamp, and day of week. Time is sourced from NTP (Network Time Protocol) and requires a WiFi connection for initial synchronization.
377
+
378
+
**Usage:**
379
+
```
380
+
WebScreen> /time
381
+
Current time: 2026-02-17 14:23:45
382
+
Epoch: 1771337025
383
+
Day of week: 2 (0=Sun)
384
+
```
385
+
386
+
**Notes:**
387
+
- Returns an error if NTP has not synced yet
388
+
- Time is displayed in the device's configured timezone
389
+
- NTP automatically syncs when WiFi connects (server: `pool.ntp.org` by default)
390
+
391
+
#### `/settime <epoch> [timezone]`
392
+
Manually sets the device time from a Unix epoch timestamp, with an optional POSIX timezone string.
0 commit comments