0

The day of week returned seems wrong sometimes. Today I executed in Google App Script engine:

Logger.log(Utilities.formatDate(new Date(), "Europe/Madrid", "yyyy-MM-dd F"))

The result was:

[15-10-26 18:18:42:037 CET] 2015-10-26 4

The problem is the final F which is translated to 4, which corresponds to Thursday. However, today is Monday, right?

The worst thing is that if I add four days to this date, I get the correct one 5 which is "Friday"

[15-10-26 18:19:50:012 CET] 2015-10-30 5

What's wrong with this code ?

1 Answer 1

1

"F" is the nth occurrence of the weekday in the month.
Today is the fourth Monday of the Month, Friday will be the fifth Friday of the month.

You probably want to use "yyyy-MM-dd u"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.