Get a date with a specific Time zone Using the Format Module

Date Object to Date string:

The following sample formats a raw number value (formatted according to the user’s preference) as a string using format.format(options).

var date = new Date();
var TOKYO = format.format({
value: date,
type: format.Type.DATETIME,
timezone: format.Timezone.ASIA_CULCUTTA
}); //Returns "12/09/2022 9:27:16 am"

Date string to Date Object:

The following sample parses a string (formatted according to the user’s preference) to a raw number value, using format.parse(options).

var dateStr = "03/17/2015 09:00:00 pm"
var TOKYO_2 = format.parse({
value: dateStr,
type: format.Type.DATETIME,
timezone: format.Timezone.ASIA_TOKYO
}); //Returns Date object [[ Tue Mar 17 2015 05:00:00 GMT-0700 (PDT) ]]

Leave a comment

Your email address will not be published. Required fields are marked *