Convert UTC Time Format to Local Date and Time format

The field JSSCHSTTIME in F91320 stores the Scheduled Start Time in UTC format e.g. value 18698955. This is a Local Date and Time format of 2005-07-21  17:15:00

JSSCHSTTIME stores the UTC time. UTC stands for Universal Time Coordinate and is a long integer containing the elapsed minutes since Midnight on January 1, 1970 in Greenwich, England.

Now lets write some code which would help converting timezones, from and to. Similarly use UTC time zone and its format effectively for Multi-Location Projects/softwares. But before hand make sure daylight saving rules (DST) are set up correctly in P00085 application. This is applicable only for countries observing DST. The Event rules (ER) along with the screen shot of the app done is given below.

UTCTimeApp


Listing of ER for Application : Test for UTC Timezones (P550003)
==================================
FORM: Fix/Inspect [FIX INSPECT] (W550003A)
==================================
CONTROL: FORM
EVENT: Post Dialog is Initialized
-----------------------------------------
// Retrieve the Current UTC Time into a Long Integer Variable
Get Current UTC Time
VA frm_SchStartTime_SCHTTIME <- BF mnCurrentUTCTime
// Display UTC Time
FC UTCTime_UTIME = utc_get_cur_time()
EVENT: Variables
frm_SchStartTime_SCHTTIME
-----------------------------------------------------------------------
CONTROL: BUTTON Convert EVENT: Button Clicked -----------------------------------------------------------------------
// Get the Local Time from UTC TimeZone
Get Time and Date From UTC
VA frm_SchStartTime_SCHTTIME -> BF mnUTCTime
FC Time Last Updated <- BF mnTime
FC Date Updated <- BF jdDate
"2" -> BF cUTC_Local
"14" -> BF szTimeZone
//
//
// Format the Time into hh:mm:ss
Format MathNumeric to Time String
FC Time Last Updated -> BF mnTime
FC FormattedTime <- BF szTime
"Zero"-> BF cFormatMode

Call Business Function “Get Time and Date From UTC” – B9800009
This function can be used to return the date and time for a UTC time in Local Date and Time format.

Get Time and Date From UTC
“18698955” -> mnUTCTime
VA frm_SchedulerStartTime_SCHSTTIME <- mnTime
FC Scheduled Start Date <- jdDate
“2” -> cUTC_Local            /* 2 stands for Local Time.   1 stands for UTC time  */
“14” -> szTimeZone          /* Check UDC H91/TZ for your country time zone. “14” is Indian Standard Time Zone */

Help From: Customer Connection Solution 200999495

1 thought on “Convert UTC Time Format to Local Date and Time format

Leave a Reply