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