Select to view content in your preferred language

Timezone in the date() function-

43
0
14 hours ago
JeffSilberberg
Frequent Contributor

I am building a new Arcade script for a Velocity Field Calculation --- 

Using the Date() functioon to retun the Epoc date.
https://developers.arcgis.com/arcade/function-reference/date_functions/#date1

My issue is that the Source data seems to use the four-character time zone, and Date() does not seem to like this. I can make this work with a DECODE for the two possible values in this routine, but that's not very generic.  

I would like to use the TimeZone Abbreviations versus the Time Zone Identifier. 

Any ideas on a better way to do this so I can pass EDT, or MDT, HST, or whatever into date() as the timeZone text value?  

// receivedDT - Thu Aug 06 10:19:35 AKDT 2026
var alphaDate = split($feature["receivedDT"], " ");
var alphaTime = split(alphaDate[3], ":");
var textYear = alphaDate[5];
var textMonth = decode(lower(alphaDate[1]), 'jan', '00', 'feb', '01', 'mar', '02', 'apr', '03', 'may', '04',
'jun', '05', 'jul', '06', 'aug', '07', 'sep', '08', 'oct', '09', 'nov', '10', 'dec', '11', 00);
var textDay = alphaDate[2];
var textTZ = decode(upper(alphaDate[4]), 'AKDT', 'US/Alaska', 'AKST', 'US/Alaska', 'US/Alaska');
var textHour = alphaTime[0];
var textMin = alphaTime[1];
var textSec = alphaTime[2];
var utcDate = Date(Number(textYear), Number(textMonth), Number(textDay),
Number(textHour), Number(textMin), Number(textSec), 0, textTZ);
Console('UtcDate: ', utcDate);

 

 

0 Kudos
0 Replies