Using the tzOffset Variable

To recreate this example, add the following fields to your application and custom form:

Field type

Database name

Display name




Local Date Time

On the Options tab, select Date and time


In this example, when the form is loaded the value of the Local Date Time field is updated to use the time zone offset that is selected by the current user in his or her user profile. This script uses the tzOffset variable, which is always accessible via JavaScript in SBM. The tzOffset variable represents the time zone offset for the given user in seconds in relation to GMT, and it can be used to make calculations like the one below.

function UpdateDateTimeField()
 var now = new Date();
 var adjustedUTCTime = now.getTime() + 
 (tzOffset * 1000) + (now.getTimezoneOffset() * 60 * 1000);
 var adjustedDate = new Date(adjustedUTCTime);
 SetFieldValue("LOCAL_DATE_TIME", adjustedDate);