toTime()

toTime()

Overview

The toTime() function takes expression, dateTimeMapping, and timeZone as arguments. It returns the expression (representing a date-time value) in the date-time format and (converted to) timezone as specified in application settings.

The dateTimeMapping param is used to specify which values in the expression stand for which date time components. The timeZone param is used to denote the time zone in which the given date-time value (in the expression) falls in.

Note: Time zone specified in application settings is considered as the default time zone.

Return Type

  • Date-time

Syntax

<variable> = <expression>.toTime( <dateTimeMapping>, <timeZone> );

(OR)

<variable> = toString( <expression>, <dateTimeMapping>, <timeZone> );
ParameterDescriptionData type
<variable>Variable which will contain the returned date-time value.DATE-TIME
<expression>

The expression (containing a valid date time format) which will be returned in date-time format.

If no time value is specified, 00:00:00 will be taken as the default time value.

When the data type is NUMBER:

  • the number 1 stands for the date-time value 31-Dec-1969 16:00:00, and every increase in 1000 will add 1 second to the date-time. value, and every decrease in 1000 will subtract 1 second from the date-time value. So, the number 1000 will return a date-time value of 31-Dec-1969 16:00:01.
  • the dateTimeMapping param is ignored, but the timeZone param is considered.

When the data type is DATE-TIME, the additional parameters (mentioned below) are ignored. And, the function will return null if the month value exceeds the number of months in a year, or the day value exceeds the number of days in a month.

TEXT

NUMBER

DATE-TIME

<dateTimeMapping>

(optional)

Applies when the given expression is of Text data type.

You can specify pattern letters to denote the various date time components in the expression as required. The pattern letters specified must be in the exact same format as given in the expression, and separated using the exact same separator as given in the expression.

When the month is specified as numerical value, the month pattern letter "M" must be specified as M or MM.

When the month is specified as a text value, the month pattern letter "M" must be specified as MMM (or may contain more number of M's).

TEXT

<timeZone>

(optional)

Applies when the given expression is of Text data type.

Time Zone in which the given date-time value will be taken. 

Value must be specified exactly as given in the TZ database name column on this page.

If the function fails to recognize the specified time zone, it will return the time value converted to GMT time zone.

TEXT

Applicable pattern letters

Letter           Date and Time component
yYear
MMonth in year
dDay in month
aam/pm marker
HHour in day (0-23)
hHour in am/pm (1-12)
mMinute in hour
sSecond in minute

Examples

dateTimeString = "01,11,19 1:30:00 pm"; 
dateTime = toTime(dateTimeString, "MM,d,yyyy hh:mm:ss a", "Europe/Moscow");         

//Assuming, date time format set in application settings is dd-MMM-yyyy and Time Zone set in application settings is Indian Standard Time (which is 2 hours and 30 minutes ahead of Moscow)
//returns 11-Jan-0019 16:00:00

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com