Time Conversions

Format

P2 Server provides functions for converting a time (in seconds since 1970 UTC) into a requested component value. The functions all require the same parameters and are used in the same way, but produce a result relevant to the function. 

Functions

Format Returns
Second(Time [,TimeZone]) Converts the specified Time into the local time zone of the machine executing the calculation, and then returns the seconds component (a value from 0 to 59).
Minute(Time [,TimeZone]) Converts the specified Time into the local time zone of the machine executing the calculation, and then returns the minutes component (a value from 0 to 59).
Hour(Time [,TimeZone]) Converts the specified Time into the local time zone of the machine executing the calculation, and then returns the hour component (a value from 0 to 23).
Day(Time [,TimeZone]) Converts the specified Time argument into the local time zone of the machine executing the calculation, and then returns the day of the month component (a value from 1 to 31).
WeekDay(Time [,TimeZone]) Converts the specified Time into the local time zone of the machine executing the calculation, and then returns the day of the week component (a value from 1 to 7, where 1 is Sunday and 7 is Saturday).
Month(Time [,TimeZone]) Converts the specified Time into the local time zone of the machine executing the calculation, and then returns the month component (a value from 1 to 12 for January to December).
Year(Time [,TimeZone])  Converts the specified Time into the local time zone of the machine executing the calculation, and then returns the four-digit year component.

Inputs

Time: The time for which to calculate the function.
Behaviour: Required
Dimension: Collection, SingleValue, MultiCollection
Valid data types: DateTime, Decimal, Integer, String

Note: You can use the Time() function to use a valid DateTime argument.

TimeZone: The geographical or UTC offset time zone (e.g. "Australia/Perth" or "UTC+08:00"). If not supplied, it assumes the configured calendar time zone. 
Behaviour: Optional
Dimension: SingleValue
Valid data types: String

How to format data types

Examples

Expression: Second(Time(), "Australia/Perth")

Expression: Minute(Time() - 60, "UTC+08:00")
Expression: Hour(Time(), "Australia/Perth")
Expression: Day(Time(), "UTC+08:00")
Expression: Weekday(Time(), "Australia/Perth")
Expression: Month(Time(), "UTC+08:00")
Expression: Year(Time(), "UTC+08:00")

Release History

  • Time Conversions 4.6.5
    • Changed Time parameter to support MultiCollection values.
  • Time Conversions 4.0
    • Initial version

Comments are closed