date-fns-timezone icon indicating copy to clipboard operation
date-fns-timezone copied to clipboard

Z character not escaped when put in square brackets

Open d4sh opened this issue 6 years ago • 2 comments

Let say I have some date in a variable called dateObject (1 July 2019 05:00:00 UTC), then doing:

formatToTimeZone(dateObject, 'DDHHmm[Z] MMM YYYY', { timeZone: 'UTC' })

should give:

010500Z Jul 2019

but instead gives:

010500+00:00 Jul 2019

I thought doing [Z] escapes the Z like the M in [GMT]????

d4sh avatar Jul 08 '19 14:07 d4sh

I have the same problem and it's really annoying 😥

MichalLytek avatar Jan 21 '20 07:01 MichalLytek

That's my use case too, however it seems Z is indeed not escaped...

Also, note that date-fns now uses ' for escaping characters

Edit: Ended up using: https://www.npmjs.com/package/date-fns-tz

TimDaub avatar Oct 12 '20 15:10 TimDaub