It’s quite weird (frustrating) that <input type=date>
gives you dates on UTC midnight as input.valueAsDate, rather than midnight local time. Thus, if you want to format the date as a string consistently with the input, you either need to convert it to local time or format it in UTC time.
For example, given a UTC date:
utc = new Date("2012-01-02")
To convert UTC to local time:
local = new Date(+utc + utc.getTimezoneOffset() * 1000 * 60)
This can then be formatted in local time:
local.toLocaleString(undefined, {month: "long", day: "numeric", year: "numeric"})
To format a UTC date in UTC time:
utc.toLocaleString(undefined, {timeZone: "utc", month: "long", day: "numeric", year: "numeric"})