Functions on Time Management

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.

This page discusses:

Functions

Function Input Types Return Type Description
STRTOTIME(str, format) String, String Integer Converts str into a date using format.

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

TIMENOW() - Integer Returns the current date and time in seconds. 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 String Converts format into a date.

Formats

The format can be defined by $ followed by one of the following characters:

Letter Description Example
A AM/PM AM
a am/pm am
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
I Hours (24) on 2 digits 04
i Hours (12) on 2 digits 04
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
M Month long name January
m Month short name jan
N Month on 2 digits 01
n Month with 1 or 2 digits 5
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
Y Year with 4 digits 1997
y Year with 2 digits 97
Z Time difference from UTC in +/-HHMM +0500
z Time zone format GMT+/-HH:MM GMT+01:00

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>".