0

I need special Date format but I got error

Format what I need: yyyy-MM-dd’T’HH:mm:ss.SSSZ

Examples of string I need:

"2000-10-31T01:30:00.000-05:00"
"2018-10-23T13:10:10.825+03:00"

My code:

var datetime = Utilities.formatDate(new Date(), "GMT+2", "yyyy-MM-ddTHH:mm:ss.SSSZ");

Error I got: Invalid argument: yyyy-MM-ddTHH:mm:ss.SSSZ (line 83, file "Code")

2 Answers 2

1

You can try this Code. This will give you the expected Result

var datetime=new Date(now.getTime()).toISOString();
Logger.log(datetime)
0
0

In the oracle documentation link in the google Apps script help , the format string to add Timezone as you want ("2018-10-23T13:10:10.825+03:00") is:

"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.