Explanation and example of DATE$() function
The DATE$() function returns today's date in various formats.
print date$ // Default format: YYYYMMDD
print date$(days(date$), 1) // Format: MMDDYYYY
print date$(days(date$), 2) // Format: DDMMYYYY
print date$(days(date$), 3) // Format: dd-Mon-yyyy
print date$(days(date$), 4) // Format: Month dd, yyyy
Explanation and example of DAYS() function
The DAYS() function returns the Julian day number for a given date.
print days('20000122') // Returns: 146119
print days('990122') // Returns: 145754
print days('20000103', 0) // Returns: 146100
print days('01032000', 1) // Returns: 146100
print days('03012000', 2) // Returns: 146100
print days('03-Jan-2000', 3)// Returns: 146100
print days('January 3, 2000', 4) // Returns: 146100
print days('2029-12-25') // Returns: 157049 (ISO 8601 dashed dates parse directly)
Explanation and example of DAY$() function
The DAY$() function returns the day of the week for a given number of days since January 1, 1600, or
for today if no integer is specified.
print day$ // Returns today's day of the week
print day$(12345) // Returns the day of the week for 12345 days since January 1, 1600
Explanation and example of FULLTIME$() function
The FULLTIME$() function returns the date and time in various
formats based on the number of seconds since January 1, 1600.
print fulltime$ // Returns current date and time
sec = seconds('20000121 115042')
print fulltime$(sec, 0) // Format: CCYYMMDD HHMMSS
print fulltime$(sec, 1) // Format: MMDDCCYY HHMMSS
print fulltime$(sec, 2) // Format: DDMMCCYY HHMMSS
print fulltime$(sec, 3) // Format: DD-Mon-CCYY HH:MM:SS
print fulltime$(sec, 4) // Format: Month DD, CCYY HH:MM:SS
Explanation and example of SECONDS() function
The SECONDS() function converts a full-time string to the
number of seconds since January 1, 1600.
z = seconds('20000122 103050') // Returns: 12624633050
z1 = seconds('990122 103050') // Returns: 12593097050
z2 = seconds('103050') // Returns: 37850 (seconds since midnight)
z3 = seconds('1030') // Returns: 37800 (seconds since midnight)
z4 = seconds('2029-12-25 14:30:00') // Returns: 13568999400 (ISO 8601)
z5 = seconds('2029-12-25T14:30:00') // Returns: 13568999400 (T separator works too)
Time zones and web timestamps
Several special seconds() forms connect Sheerpower's clock to
the outside world. seconds('utc') returns the current
time in Coordinated Universal Time instead of local time, and
seconds('utcoffset') returns this machine's offset from
UTC in signed seconds (local minus UTC — a machine on
US Pacific daylight time returns -25200).
Web APIs speak unix time — seconds since January 1,
1970 UTC. seconds('unix') returns the current time on
that scale, and seconds('unix:<number>') converts
a unix timestamp from an API into local Sheerpower seconds,
ready for fulltime$().
print seconds('utcoffset') // Returns: -25200 (7 hours behind UTC)
print seconds('unix') // Returns: 1787358794 (now, unix scale)
// render an API timestamp as local time:
print fulltime$(seconds('unix:1787354616'), 3) // Returns: 21-Aug-2026 16:23:36
// how old is a webhook? (providers send t = a unix timestamp)
age = seconds('unix') - webhook_t
ISO 8601 datetimes with a time zone convert automatically: a
trailing Z means UTC, and a +hh:mm or
-hh:mm suffix names its offset. Either way the result
is in local time (using the machine's current UTC offset).
print fulltime$(seconds('2029-12-25T14:30:00Z'), 3)
// Returns: 25-Dec-2029 07:30:00 (local)
Going the other direction — producing a
standards-complete timestamp — is one sprintf$()
item: @ts emits the full RFC 3339 form, date, time and
UTC offset together.
print sprintf$('%t@ts', 0) // Returns: 2026-08-21T18:04:59-07:00
print sprintf$('%t@ts', seconds('2029-12-25 14:30:00'))
// Returns: 2029-12-25T14:30:00-07:00
Explanation and example of TIME() function
The TIME() function returns various time values based on the input integer.
print time(0) // Returns: Seconds since midnight
print time(1) // Returns: CPU time of the process
print time(2) // Returns: Connect time of the process
print time(5) // Returns: Seconds since Sheerpower was invoked
Explanation and example of TIME$() function
The TIME$() function returns the current time in HH:MM:SS format, or
the time based on the number of seconds since midnight if specified.
print time$ // Returns current time of day
print time$(1800) // Returns: 00:30
print time$(54178) // Returns: 15:02
Sheerpower has many more ways to work with date and time-related operations. See
here
for more details.