Time
for more info on the ISO8601 format see: https://en.wikipedia.org/wiki/ISO_8601
- epochToFormatted
- converts epoch to custom readable string
- epochToISO8601
- converts the epoch to an string in the ISO8601 format https://wikipedia.org/wiki/ISO_8601
- getApproximateTimeDescription
- This returns a string that roughly describes how long ago this time was, which can be handy for showing ages of files, etc. This will only attempt to be accurate to within the nearest order of magnitude so returns strings such as "5 years", "2 weeks", "< 1 minute", "< 1 sec" etc.
- getCurrentEpoch
- gets the current system time in epoch format
- getTimeComponents
- returns a relative time in human readable components; weeks, days, hours, minutes, seconds and milliseconds
- getTimeDescription
- Returns a readable textual description of the time. The exact format of the string returned will depend on the magnitude of the time e.g. "1 min 4 secs", "1 hr 45 mins", "2 weeks 5 days", "140 ms" so that only the two most significant units are printed.
- ISO8601ToEpoch
- converts a ISO8601 string to epoch
examples
// read and convert the epoch time format to human readable format
function TestTime()
{
var now = getCurrentEpoch(); // secs since 1 jan 1970
var ISO8601_string = epochToISO8601(now); // convert to readable string, for format see https://en.wikipedia.org/wiki/ISO_8601
echo("time/date: " + ISO8601_string);
var epochFromStr = ISO8601ToEpoch(ISO8601_string); // convert the string back to epoch
echo(epochToFormatted(epochFromStr, "%A %B %d %Y")); // convert epoch to custom readable string
}