Functions on Time

This page provides an extract of frequently used functions using time.

The time value can be provided by:

  • The TIMENOW function, presented below.
  • A date of a PLM object. For example, the Originated parameter provides a date.

Function Input Types Return Type Description
TIMENOW() - Integer Returns the current date and time in milliseconds. The reference date is 1 January 1970.
Note: TIMENOW uses the server's system time, so it does not take the user preference into account. To work in a given time zone, the workaround can be adding or removing the requested numberOfHours * 3600.
TIMETOSTR(time, format) Integer, String Integer Converts format into a date.
STRTOTIME(str, format) String, String Integer Converts str into a date using format.

Example: STRTOTIME("3/26/2007", "$N/$D/$Y") returns 1174903200.

The format is composed of the following characters:

Letter Description Example
M Month long name January
m Month short name jan
J Day of week long name Monday
j Day of week short name (3 chars) mon
K Day of week very short name (2 chars) mo
Y Year with 4 digits 1997
y Year with 2 digits 97
N Month on 2 digits 01
n Month with 1 or 2 digits 5
D Month day on 2 digits 03
d Month day with 1 or 2 digits 3
H Hours (24) with 1 or 2 digits 4
h Hours (12) with 1 or 2 digits 4
U Minutes on 2 digits 05
u Minutes on 1 or 2 digits 5
S Seconds on 2 digits 07
s Seconds on 1 or 2 digits 7
I Hours (24) on 2 digits 04
i Hours (12) on 2 digits 04
A AM/PM AM
a am/pm am

Example: Retrieving the Creation Date

To retrieve the originated date of a PLM object and give the format month/day/year, you must execute the following actions:

  • Format the value given by the TIMENOW function using the STRTOTIME function
  • Transform the result using the TIMETOSTR function, such as follows:TIMETOSTR(STRTOTIME(<param>.originated, "$m $D, $Y"), "$N/$D/$Y"), where <param> represents the name of the data.

The format "$m $D, $Y" means "<monthShortName> <day2Digits>, <year4digits>".