Skip to content

Time Util API

  • Deprecation Notice: This is now deprecated, and its usage is not recommended. Please migrate to TIME_SYS

It’s important to remember that regardless of time zone used to display the value in the client, the server side will be storing it in UTC.

To convert the date values related to time zones, a set of methods have been introduced in the TimeUtil utility package. (Time_Util_API). This package is in FNDBAS component.

Please note that Timezone identifiers can be specified using the following formats

  • ISO standard (E.g. Asia/Colombo) – Recommended

  • Offset (+5:30)

  • UTC/GMT

The following methods are included.

  • Convert_Timezone :

Converts a Date value in a given time zone (from_timezone_) to a different time zone (to_timezone).

  • Convert_Utc_To_Timezone :

Converts a date value in UTC time zone to a different Timezone (to_timezone_).

  • Convert_Timezone_To_Utc :

Converts a date in a given time zone (from_timezone_) to UTC.

  • Convert_To_System_Timezone :

Converts a date in a given time zone (from_timezone_) to the time zone the database is running (NOTE: This is the time zone of the Database Server and not the DBTIMEZONE value).

  • Get_Sysdate_In_Utc :

Get the current time in UTC.

  • Get_Current_Time_In_Timezone :

Get’s the current time in a given time zone.

  • Get_Current_Time_Difference :

Get the time difference between two time zones, if first_timezone is a head of second Timezone the value will be a positive number, otherwise it will be a negative number. This can be directly added/subtracted from date fields to do calculations.

  • Get_Cur_Server_Time_Difference :

Get the time difference between the server time and a given time zone, if the server is a head of the given time zone the value will be a positive number, otherwise it will be a negative number. This can be directly added/subtracted from date fields to do calculations.

  • Get_UTC_Offset :

Get the offset of the DB time to UTC. Returns the offset as a string. As an example if the offset is positive the return value is like "+02:00" and otherwise return value is like "-02:00".

  • Get_UTC_Offset(time_zone) :

Get the current offset to UTC for a given time zone. Day light saving is applied to the output value. Return type and the format is same as Get_UTC_Offset function.

  • Get_UTC_Offset(time_zone, date) :

Get the offset to UTC for a given time zone and a given date.Day light saving is applied to the output value. Return type and the format is same as Get_UTC_Offset function.

  • Convert_Server_Time_To_Utc :

Convert a time given in server time to UTC.

  • Get_Offset_Date_Difference :

Get the days-difference for a given offset. As an example if the given offset is '+06:00', the output value is 0.25. If a negative offset is given the output value is a negative value. If the offset is invalid format, IOFERROR: Offset is in invalid format error is raised. Below formats are some examples for invalid format.
Ex: "06:00C", "ABC". "+6:00"