cancel
Showing results for 
Search instead for 
Did you mean: 

Convert UTC date to date

mtran21
New Contributor III

How do you convert this date “2020-09-01T00:00:00.000” to this “20200901”?

11 REPLIES 11

dmiller
Admin Admin
Admin

I’m double checking, but I think you have to use one of the formats listed in the Parsing a Date example in the documentation.


Diane Miller
Community Manager

dmiller
Admin Admin
Admin

@cjhoward18 to the rescue. 🙂
Date.parse("2020-09-01T00:00:00.000").toLocaleDateString({"format":"yyyyMMdd"})


Diane Miller
Community Manager

mtran21
New Contributor III

Thanks, will this work with variable?
Date.parse(“$HIRE_DATE”).toLocaleDateString({“format”:“yyyyMMdd”})

dmiller
Admin Admin
Admin

You shouldn’t need the quotes around the variable, but it should work if it’s a string.


Diane Miller
Community Manager