I am using the date-fns
library to format a javascript date
object to a specific format. date-fns
uses the Unicode date field symbols. In this table documenting the symbols, there is a distinction between "local" (ie, local day of week: e
) and symbols that aren't local (day of week: E
). There are also ISO versions of this (ISO day of week: i
), as well as stand-alone versions.
I get that when formatting complete dates, I should not be using the stand-alone versions. But I am less clear on the difference between local, non-local, and ISO.
My question: assuming this is the date:
const date = new Date('2021-04-12')
Assuming I want to print out Monday, April 12
, everywhere in the world irrespective of time zone, What is the difference between these:
format(date, 'EEEE, MMMM d.')
day of week
format(date, 'iiii, MMMM d.')
ISO day of week
format(date, 'eeee, MMMM d.')
local day of week
Do they depend on what the local user time is? I saw this issue which suggests I need to use getTimezoneOffset()
to make sure the time is consistent everywhere. But I wasn't sure how the Unicode symbols affect what gets displayed.