CurrentTime

(Engine-Level Function)

Description: Returns the number of seconds, in local or UTC time, since midnight of January 1, 1970 (where "midnight" is 00:00).
Returns: Numeric (double)
Usage: Script only.
Function Groups: Time and Date
Related to: Now | Seconds | Today | TimeArrived
Format: CurrentTime([TimeType] )
Parameters:  
TimeType
Any expression that evaluates to a 0 or 1. When 0, it indicates that time returned should be local time.
If set to 1, indicates that the current UTC time should be returned.
Defaults to 0 if missing or Invalid.
 
Comments:

This function solves the problem encountered when using Seconds together with Today to determine the current date and time, when the time is within a fraction of a second of midnight.
This function assumes that "midnight" on January 1, 1970 is 00:00, rather than 24:00 on a 24-hour clock.
The returned value is accurate to three decimal points (milliseconds).

Refer to the notes at the end of Working in Steady State for an example of how to use this (and similar) functions in a Steady State context.

Example 1:

  If ! Valid(RightNow);
  [
    RightNow = CurrentTime(); 
  ]

This assigns the current time in seconds since midnight on January 1, 1970 to the double variable RightNow.

Example 2:

You may have a need to format a CurrentTime value for display to a user.

Given that there are 86400 seconds in a day, you can format the timestamp as follows:

  If ! Valid(LocalNow);
  [
    LocalNow = CurrentTime(0); 
    DisplayNow = concat(Date(LocalNow / 86400, 4), " - ", 
                             Time(LocalNow % 86400, 2));
  ]