Choose where you’d like to start

unixEpoch

Overview

The unixEpoch function calculates the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970.

Note:

  • The date-time expression has to be in text format to enable the conversion. If any other date-type is supplied, a run-time error is encountered.
  • The conversion is done based on time zones. If no timezone is provided, the timezone set in the application will be applied. If an invalid timezone is provided, the timezone is defaulted to GMT(see example below).
  • If the function fails to recognise the date-time value, it will simply return the given value in text format.
  • Leap seconds are not included for lapsed time

Return Type

  • NUMBER

Syntax

<variable> = <dateText>.unixEpoch([<timeZone>]);

where,

ParameterData typeDescription
<variable>NUMBERVariable which will contain the returned value.
<dateText>TEXTThe expression which will be returned in text format.

<timeZone>

(optional)

TEXT

Time zone in which the time elapsed in milliseconds should be calculated.

Value must be specified exactly as given in the TZ database name.

If no timezone or an invalid timezone is provided, the timezone is defaulted to GMT.

Applicable Date-Time Literals

LetterDate and Time Component
Era designator
y

Calendar year

Examples:

y - 2019

yy -19

yyy  - 2019

dateValue = '29-Dec-2019';
info dateValue.toText("yyyy"); // returns 2019

Y

Week year

Examples:

Y - 2019

YY -19

YYY  - 2019

dateValue = '29-Dec-2019';
info dateValue.toText("YYYY"); // returns 2020

M

Month in year

Examples:

M - 1

MM - 01

MMM - January

wWeek in year
WWeek in month
DDay in year
dDay in month
FDay of week in month
E

Day name in week

Examples:

E - Tue

EEEE - Tuesday

uDay number of week
aam/pm marker
HHour in day (0-23)
kHour in day (1-24)
KHour in am/pm (0-11)
hHour in am/pm (1-12)
mMinute in hour
sSecond in minute
SMillisecond
zGeneral time zone
ZRFC time zone
XISO 8601 time zone

Examples

 currentDate = "03-Feb-2020 03:48:12";
 indiaTime  =  currentDate.unixEpoch("Asia/Calcutta"); // 1580681892000
 gmtMinus8  =  currentDate.unixEpoch("GMT-8"); // 1580730492000
 default  =  currentDate.unixEpoch(); // 1580730492000
 utcPlus8  =  currentDate.unixEpoch("UTC+8"); // 1580701692000
 gmt  =  currentDate.unixEpoch("GMT"); // 1580701692000
 indiaGMT  =  currentDate.unixEpoch("GMT+5:30"); // 1580681892000
 est  =  currentDate.unixEpoch("EST"); // 1580719692000
 sst  =  currentDate.unixEpoch("SST"); // 1580662092000
 invalidTZ  =  currentDate.unixEpoch("Hello"); // Invalid timezone. So, defaulted to GMT. 1580701692000
 invalidType  =  '03-Feb-2020 03:48:12'.unixEpoch("GMT"); // Run-time error

Related Links

Get Started Now

Execute