Hi all,
Could anyone assist me in converting the following String type field
Mon Sep 17 13:11:06 +0000 2018
into a Date type field?
Thanks,
Gee
Solved! Go to Solution.
Thanks this worked for me as well. Is there a way to tell it that this is UTC time, and that it should adjust to whatever time zone the user is in when displaying?
For example, my expression converts text (2019-03-19 20:00:00, UTC) to
Tue Mar 19 2019 20:00:00 GMT-0500 (Central Daylight Time)
even though it doesn't convert it to CDT.
There is a "ToLocal" function within Arcade expressions that I was able to use.
I worked through this issue today and was able to use both the codes in this thread to make my situation work. I had a date in a string format that had inconsistent amount of characters e.g. 1/2/2016; 6/22/2017; 12/12/2018. Using a split array and a dictionary worked well. Thanks Xander Bakker and Geethaka Fernando
My code:
var date_text = $feature["START_DATE"]
function Convert2Date(date_text){
// Month List
var months = {"1": 0, "2": 1, "3": 2, "4": 3, "5": 4, "6": 5, "7": 6, "8": 7, "9": 8, "10": 9, "11": 10, "12": 11};
// Date List
var date_list = Split(date_text, '/')
// Year
var yearNum = Number(date_list[2]);
// Month
var monthNum = months[date_list[0]];// Day
var dayNum = Number(date_list[1]);return Date(yearNum,monthNum,dayNum);
}return Convert2date(date_text);