The time command can be used to do various time conversions. It can also track the number of days until (due) or since a specified time.
This command looks first for the when parameter, then the value of parameter 1. It can be a timestamp, or a time expression that PHP understands (using strtotime). If no valid time is found, the current time is used. PHP can recognize a pretty amazing variety of time expressions.
The fmt is defined by the fmt parameter, or the second parameter, or even the first parameter. If no fmt is found it uses the timeFmt config value as set in site.config, or the default value of %c (which returns a date and time string). It can take any value PHP understands (using strftime) and can output about any time expression you would want.
To use this function effectively it is helpful to know a bit about timestamps and PHP works with them. Here are links to some info on www.php.net/strtotime and www.php.net/strftime at the PHP site.
BoltWire make a few minor additions to what is normally available in PHP to make up for a couple weaknesses and to add a little extra functionality.
fmt=due will return the number of days until the specified time
fmt=since will return the number of days since the specified time
fmt=timestamp of fmt=%s will cause the command to return a timestamp.
%e in the fmt is replaced with the day of the month without a leading 0
%E in the fmt is replaced with the number for the month without a leading 0
Here's a simple example of how the function works:
Outputs the current time, default format (Fri Jul 30 23:07:10 2021)
<(time 'Next Thursday')>
Returns next Thursday, in the default format (Thu Aug 5 00:00:00 2021)
Returns the current time in a custom fmt (2021-7-30)
<(time '+2 hours' '%H:%M:%S')>
Returns the time in two hours (01:07:10)
<(time 'March 31, 2015' fmt=due)>
How many days until the specified date (Tue Mar 31 00:00:00 2015)
<(time '01/01/2000' fmt=since)>
How many days since the specified date (Fri Jul 30 23:07:10 2021)
Time ZonesThe time functions in PHP are set to use Greenwich Mean Time (GMT) which may not be what you want to use for you installation. BoltWire has the ability to set your local time zone. Just set localTime in site.config to the number of hours difference between your zone and GMT. This site is set on "localTime: 6" for Central Standard Time. In the USA, use the following:
EST - 5
CST - 6
MST - 7
PST - 8