Skip to main content
Adaptive Insights
Knowledge and Support - Adaptive Insights

Adaptive Date

ai.date

The ai.date namespace allows users to create ISO8601 datetime strings, as well as convert them into different timezones. Read more about ISO8601 here.

 

Method Parameters Return Type Description

create( date, sourceTz, format )

  • date : String
    Date string base

  • sourceTz : String Timezone to create date in

  • format : String
    Optional - Format string to assist parsing date

String

Creates an ISO8601 formatted datetime string including date, time and timezone offset, from a partial datetime string, timezone and optional format string. Tokens for a valid format string can be found below.

IMPORTANT: If date is not a valid ISO8601 string, then you must provide a format string in order to successfully parse and create a datestring.

convertTimezone( date, targetTz )

  • date : Date/String Date to convert
  • targetTz : String Timezone to convert date to

String

Converts a JavaScript date object or valid ISO8601 date string from one timezone into another. The return value is an ISO8601 date string formatted in the target timezone. Valid values for timezones can be found below.

getServerTimezone()

 

String

Returns the Integration servers' timezone. Any new date objects created in user scripts will be treated as in the servers' timezone.

getSupportedTimezones()

 

Array<String>

Returns an array containing all valid timezones for use in convertTimezone().

 

Supported Timezones

Africa/Abidjan

America/Grand_Turk

Asia/Amman

Australia/North

Europe/Vaduz

Africa/Accra

America/Grenada

Asia/Anadyr

Australia/Perth

Europe/Vatican

Africa/Addis_Ababa

America/Guadeloupe

Asia/Aqtau

Australia/Queensland

Europe/Vienna

Africa/Algiers

America/Guatemala

Asia/Aqtobe

Australia/South

Europe/Vilnius

Africa/Asmara

America/Guayaquil

Asia/Ashgabat

Australia/Sydney

Europe/Volgograd

Africa/Asmera

America/Guyana

Asia/Ashkhabad

Australia/Tasmania

Europe/Warsaw

Africa/Bamako

America/Halifax

Asia/Baghdad

Australia/Victoria

Europe/Zagreb

Africa/Bangui

America/Havana

Asia/Bahrain

Australia/West

Europe/Zaporozhye

Africa/Banjul

America/Hermosillo

Asia/Baku

Australia/Yancowinna

Europe/Zurich

Africa/Bissau

America/Indiana/Indianapolis

Asia/Bangkok

Brazil/Acre

GB

Africa/Blantyre

America/Indiana/Knox

Asia/Beirut

Brazil/DeNoronha

GB-Eire

Africa/Brazzaville

America/Indiana/Marengo

Asia/Bishkek

Brazil/East

GMT

Africa/Bujumbura

America/Indiana/Petersburg

Asia/Brunei

Brazil/West

GMT+0

Africa/Cairo

America/Indiana/Tell_City

Asia/Calcutta

CET

GMT-0

Africa/Casablanca

America/Indiana/Vevay

Asia/Chita

CST6CDT

GMT0

Africa/Ceuta

America/Indiana/Vincennes

Asia/Choibalsan

Canada/Atlantic

Greenwich

Africa/Conakry

America/Indiana/Winamac

Asia/Chongqing

Canada/Central

HST

Africa/Dakar

America/Indianapolis

Asia/Chungking

Canada/East-Saskatchewan

Hongkong

Africa/Dar_es_Salaam

America/Inuvik

Asia/Colombo

Canada/Eastern

Iceland

Africa/Djibouti

America/Iqaluit

Asia/Dacca

Canada/Mountain

Indian/Antananarivo

Africa/Douala

America/Jamaica

Asia/Damascus

Canada/Newfoundland

Indian/Chagos

Africa/El_Aaiun

America/Jujuy

Asia/Dhaka

Canada/Pacific

Indian/Christmas

Africa/Freetown

America/Juneau

Asia/Dili

Canada/Saskatchewan

Indian/Cocos

Africa/Gaborone

America/Kentucky/Louisville

Asia/Dubai

Canada/Yukon

Indian/Comoro

Africa/Harare

America/Kentucky/Monticello

Asia/Dushanbe

Chile/Continental

Indian/Kerguelen

Africa/Johannesburg

America/Knox_IN

Asia/Gaza

Chile/EasterIsland

Indian/Mahe

Africa/Juba

America/Kralendijk

Asia/Harbin

Cuba

Indian/Maldives

Africa/Kampala

America/La_Paz

Asia/Hebron

EET

Indian/Mauritius

Africa/Khartoum

America/Lima

Asia/Ho_Chi_Minh

EST

Indian/Mayotte

Africa/Kigali

America/Los_Angeles

Asia/Hong_Kong

EST5EDT

Indian/Reunion

Africa/Kinshasa

America/Louisville

Asia/Hovd

Egypt

Iran

Africa/Lagos

America/Lower_Princes

Asia/Irkutsk

Eire

Israel

Africa/Libreville

America/Maceio

Asia/Istanbul

Etc/GMT

Jamaica

Africa/Lome

America/Managua

Asia/Jakarta

Etc/GMT+0

Japan

Africa/Luanda

America/Manaus

Asia/Jayapura

Etc/GMT+1

Kwajalein

Africa/Lubumbashi

America/Marigot

Asia/Jerusalem

Etc/GMT+10

Libya

Africa/Lusaka

America/Martinique

Asia/Kabul

Etc/GMT+11

MET

Africa/Malabo

America/Matamoros

Asia/Kamchatka

Etc/GMT+12

MST

Africa/Maputo

America/Mazatlan

Asia/Karachi

Etc/GMT+2

MST7MDT

Africa/Maseru

America/Mendoza

Asia/Kashgar

Etc/GMT+3

Mexico/BajaNorte

Africa/Mbabane

America/Menominee

Asia/Kathmandu

Etc/GMT+4

Mexico/BajaSur

Africa/Mogadishu

America/Merida

Asia/Katmandu

Etc/GMT+5

Mexico/General

Africa/Monrovia

America/Metlakatla

Asia/Khandyga

Etc/GMT+6

NZ

Africa/Nairobi

America/Mexico_City

Asia/Kolkata

Etc/GMT+7

NZ-CHAT

Africa/Ndjamena

America/Miquelon

Asia/Krasnoyarsk

Etc/GMT+8

Navajo

Africa/Niamey

America/Moncton

Asia/Kuala_Lumpur

Etc/GMT+9

PRC

Africa/Nouakchott

America/Monterrey

Asia/Kuching

Etc/GMT-0

PST8PDT

Africa/Ouagadougou

America/Montevideo

Asia/Kuwait

Etc/GMT-1

Pacific/Apia

Africa/Porto-Novo

America/Montreal

Asia/Macao

Etc/GMT-10

Pacific/Auckland

Africa/Sao_Tome

America/Montserrat

Asia/Macau

Etc/GMT-11

Pacific/Bougainville

Africa/Timbuktu

America/Nassau

Asia/Magadan

Etc/GMT-12

Pacific/Chatham

Africa/Tripoli

America/New_York

Asia/Makassar

Etc/GMT-13

Pacific/Chuuk

Africa/Tunis

America/Nipigon

Asia/Manila

Etc/GMT-14

Pacific/Easter

Africa/Windhoek

America/Nome

Asia/Muscat

Etc/GMT-2

Pacific/Efate

America/Adak

America/Noronha

Asia/Nicosia

Etc/GMT-3

Pacific/Enderbury

America/Anchorage

America/North_Dakota/Beulah

Asia/Novokuznetsk

Etc/GMT-4

Pacific/Fakaofo

America/Anguilla

America/North_Dakota/Center

Asia/Novosibirsk

Etc/GMT-5

Pacific/Fiji

America/Antigua

America/North_Dakota/New_Salem

Asia/Omsk

Etc/GMT-6

Pacific/Funafuti

America/Araguaina

America/Ojinaga

Asia/Oral

Etc/GMT-7

Pacific/Galapagos

America/Argentina/Buenos_Aires

America/Panama

Asia/Phnom_Penh

Etc/GMT-8

Pacific/Gambier

America/Argentina/Catamarca

America/Pangnirtung

Asia/Pontianak

Etc/GMT-9

Pacific/Guadalcanal

America/Argentina/ComodRivadavia

America/Paramaribo

Asia/Pyongyang

Etc/GMT0

Pacific/Guam

America/Argentina/Cordoba

America/Phoenix

Asia/Qatar

Etc/Greenwich

Pacific/Honolulu

America/Argentina/Jujuy

America/Port-au-Prince

Asia/Qyzylorda

Etc/UCT

Pacific/Johnston

America/Argentina/La_Rioja

America/Port_of_Spain

Asia/Rangoon

Etc/UTC

Pacific/Kiritimati

America/Argentina/Mendoza

America/Porto_Acre

Asia/Riyadh

Etc/Universal

Pacific/Kosrae

America/Argentina/Rio_Gallegos

America/Porto_Velho

Asia/Saigon

Etc/Zulu

Pacific/Kwajalein

America/Argentina/Salta

America/Puerto_Rico

Asia/Sakhalin

Europe/Amsterdam

Pacific/Majuro

America/Argentina/San_Juan

America/Rainy_River

Asia/Samarkand

Europe/Andorra

Pacific/Marquesas

America/Argentina/San_Luis

America/Rankin_Inlet

Asia/Seoul

Europe/Athens

Pacific/Midway

America/Argentina/Tucuman

America/Recife

Asia/Shanghai

Europe/Belfast

Pacific/Nauru

America/Argentina/Ushuaia

America/Regina

Asia/Singapore

Europe/Belgrade

Pacific/Niue

America/Aruba

America/Resolute

Asia/Srednekolymsk

Europe/Berlin

Pacific/Norfolk

America/Asuncion

America/Rio_Branco

Asia/Taipei

Europe/Bratislava

Pacific/Noumea

America/Atikokan

America/Rosario

Asia/Tashkent

Europe/Brussels

Pacific/Pago_Pago

America/Atka

America/Santa_Isabel

Asia/Tbilisi

Europe/Bucharest

Pacific/Palau

America/Bahia

America/Santarem

Asia/Tehran

Europe/Budapest

Pacific/Pitcairn

America/Bahia_Banderas

America/Santiago

Asia/Tel_Aviv

Europe/Busingen

Pacific/Pohnpei

America/Barbados

America/Santo_Domingo

Asia/Thimbu

Europe/Chisinau

Pacific/Ponape

America/Belem

America/Sao_Paulo

Asia/Thimphu

Europe/Copenhagen

Pacific/Port_Moresby

America/Belize

America/Scoresbysund

Asia/Tokyo

Europe/Dublin

Pacific/Rarotonga

America/Blanc-Sablon

America/Shiprock

Asia/Ujung_Pandang

Europe/Gibraltar

Pacific/Saipan

America/Boa_Vista

America/Sitka

Asia/Ulaanbaatar

Europe/Guernsey

Pacific/Samoa

America/Bogota

America/St_Barthelemy

Asia/Ulan_Bator

Europe/Helsinki

Pacific/Tahiti

America/Boise

America/St_Johns

Asia/Urumqi

Europe/Isle_of_Man

Pacific/Tarawa

America/Buenos_Aires

America/St_Kitts

Asia/Ust-Nera

Europe/Istanbul

Pacific/Tongatapu

America/Cambridge_Bay

America/St_Lucia

Asia/Vientiane

Europe/Jersey

Pacific/Truk

America/Campo_Grande

America/St_Thomas

Asia/Vladivostok

Europe/Kaliningrad

Pacific/Wake

America/Cancun

America/St_Vincent

Asia/Yakutsk

Europe/Kiev

Pacific/Wallis

America/Caracas

America/Swift_Current

Asia/Yekaterinburg

Europe/Lisbon

Pacific/Yap

America/Catamarca

America/Tegucigalpa

Asia/Yerevan

Europe/Ljubljana

Poland

America/Cayenne

America/Thule

Atlantic/Azores

Europe/London

Portugal

America/Cayman

America/Thunder_Bay

Atlantic/Bermuda

Europe/Luxembourg

ROC

America/Chicago

America/Tijuana

Atlantic/Canary

Europe/Madrid

ROK

America/Chihuahua

America/Toronto

Atlantic/Cape_Verde

Europe/Malta

Singapore

America/Coral_Harbour

America/Tortola

Atlantic/Faeroe

Europe/Mariehamn

Turkey

America/Cordoba

America/Vancouver

Atlantic/Faroe

Europe/Minsk

UCT

America/Costa_Rica

America/Virgin

Atlantic/Jan_Mayen

Europe/Monaco

US/Alaska

America/Creston

America/Whitehorse

Atlantic/Madeira

Europe/Moscow

US/Aleutian

America/Cuiaba

America/Winnipeg

Atlantic/Reykjavik

Europe/Nicosia

US/Arizona

America/Curacao

America/Yakutat

Atlantic/South_Georgia

Europe/Oslo

US/Central

America/Danmarkshavn

America/Yellowknife

Atlantic/St_Helena

Europe/Paris

US/East-Indiana

America/Dawson

Antarctica/Casey

Atlantic/Stanley

Europe/Podgorica

US/Eastern

America/Dawson_Creek

Antarctica/Davis

Australia/ACT

Europe/Prague

US/Hawaii

America/Denver

Antarctica/DumontDUrville

Australia/Adelaide

Europe/Riga

US/Indiana-Starke

America/Detroit

Antarctica/Macquarie

Australia/Brisbane

Europe/Rome

US/Michigan

America/Dominica

Antarctica/Mawson

Australia/Broken_Hill

Europe/Samara

US/Mountain

America/Edmonton

Antarctica/McMurdo

Australia/Canberra

Europe/San_Marino

US/Pacific

America/Eirunepe

Antarctica/Palmer

Australia/Currie

Europe/Sarajevo

US/Pacific-New

America/El_Salvador

Antarctica/Rothera

Australia/Darwin

Europe/Simferopol

US/Samoa

America/Ensenada

Antarctica/South_Pole

Australia/Eucla

Europe/Skopje

UTC

America/Fort_Nelson

Antarctica/Syowa

Australia/Hobart

Europe/Sofia

Universal

America/Fort_Wayne

Antarctica/Troll

Australia/LHI

Europe/Stockholm

W-SU

America/Fortaleza

Antarctica/Vostok

Australia/Lindeman

Europe/Tallinn

WET

America/Glace_Bay

Arctic/Longyearbyen

Australia/Lord_Howe

Europe/Tirane

Zulu

America/Godthab

Asia/Aden

Australia/Melbourne

Europe/Tiraspol

 

America/Goose_Bay

Asia/Almaty

Australia/NSW

Europe/Uzhgorod

 

Supported Date Format String Tokens

Non-alphanumeric characters are ignored by the parser.

Year, Month, and Day Tokens

Input Example Description

YYYY

2014

4 or 2 digit year

YY

14

2 digit year

Q

1..4

Quarter of year. Sets month to first month in quarter.

M MM

1..12

Month number

MMM MMMM

Jan..December

Month name in locale

D DD

1..31

Day of month

Do

1st..31st

Day of month with ordinal

DDD DDDD

1..365

Day of year

X

1410715640.579

Unix timestamp

x

1410715640579

Unix ms timestamp

YYYY from version 2.10.5 supports 2 digit years, and converts them to a year near 2000 (same as YY).

Week Year, Week, and Weekday Tokens

For these, the lowercase tokens use the locale aware week start days, and the uppercase tokens use the ISO week date start days.

Input Example Description
gggg 2014 Locale 4 digit week year
gg 14 Locale 2 digit week year
w ww 1..53 Locale week of year
e 1..7 Locale day of week
ddd dddd Mon...Sunday Day name in locale
GGGG 2014 ISO 4 digit week year
GG 14 ISO 2 digit week year
W WW 1..53 ISO week of year
E 1..7 ISO day of week

Hour, Minute, Second, Millisecond, and Offset Tokens

Input

Example

Description

H HH

0..23

24 hour time

h hh

1..12

12 hour time used with a A.

a A

am pm

Post or ante meridiem

m mm

0..59

Minutes

s ss

0..59

Seconds

S SS SSS

0..999

Fractional seconds

Z ZZ

+12:00

Offset from UTC as +-HH:mm, +-HHmm, or Z

Creating ISO8601 Datetime Strings

// create a date from a date fragment that is in ISO8601 format
var date = ai.date.create('2016-02-01', 'America/Los_Angeles');
// date is "2016-02-01T00:00:00-08:00"
 
// create a date from a date fragment that is NOT in ISO8601 format
var date = ai.date.create('02/01/2016', 'America/Los_Angeles', 'MM/DD/YYYY');
// date is "2016-02-01T00:00:00-08:00"
 
// create a date from a date fragment that is NOT in ISO8601 format, but in Australian format
var date = ai.date.create('02/01/2016', 'America/Los_Angeles', 'DD/MM/YYYY');
// date is "2016-01-02T00:00:00-08:00"
 
// create a date from a date and time fragment, but no offset, fragment is in ISO8601 format.
var date = ai.date.create('2016-02-01T05:00', 'America/Los_Angeles');
// date is "2016-02-01T05:00:00-08:00"
 
var date = ai.date.create('2016-02-01 05:00', 'America/Los_Angeles');
// date is "2016-02-01T05:00:00-08:00"
 
// create a date that includes daylight savings
var date = ai.date.create('2016-02-01 12:00', 'Australia/Sydney');
// date is "2016-02-01T12:00:00+11:00"
 
// without daylight savings...
var date = ai.date.create('2016-06-01 12:00', 'Australia/Sydney');
// date is "2016-02-01T12:00:00+10:00"
 
// create a date in UTC
var date = ai.date.create('2016-03-01', 'UTC');
// date is "2016-03-01T00:00:00+00:00"

Converting ISO8601 Datetime Strings

// convert Brisbane to Sydney time with daylight savings
var date = ai.date.convertTimezone(new Date('2015-01-15T12:00:00+10:00'), 'Australia/Sydney');
// date is "2015-01-15T13:00:00+11:00"
 
// convert Brisbane to Sydney time without daylight savings
var date = ai.date.convertTimezone('2015-06-15T12:00:00+10:00', 'Australia/Sydney');
// date is "2015-06-15T12:00:00+10:00"
 
// convert Brisbane to New York time
var date = ai.date.convertTimezone('2015-06-15T12:00:00+10:00', 'America/New_York');
// date is "2015-06-14T22:00:00-04:00"
 
// convert New York to Brisbane time
var date = ai.date.convertTimezone('2015-06-15T12:00:00-04:00', 'Australia/Brisbane');
date is "2015-06-16T02:00:00+10:00"
 
// convert New York to UTC time
var date = ai.date.convertTimezone('2015-06-15T12:00:00-04:00', 'UTC');  
// date is "2015-06-15T16:00:00+00:00"

Getting Server Timezone

var serverTz = ai.date.getServerTimezone();
// as an example, serverTz = 'America/Los_Angeles'

Getting All Supported Timezones

var timezones = ai.date.getSupportedTimezones();
// timezones is an array containing the above 583 timezones
  • Was this article helpful?