Open
Description
Hi Guys,
I'm currently replacing moment-js
with date-fns
, but when it comes to timezone, I'm unable to get the same value.
Do you guys know what am I doing wrong?
const moment = require('moment-timezone');
const dateFNS = require('date-fns');
const dateFNSTimezone = require('date-fns-timezone');
const { format } = dateFNS;
const { convertToTimeZone } = dateFNSTimezone;
const TZ = 'America/Los_Angeles';
const a = moment().tz(TZ).format();
const b = format(convertToTimeZone(new Date(), { timeZone: TZ }), 'YYYY-MM-DDTHH:mm:ssZ');
console.log(a); // 2019-02-11T09:28:29-08:00
console.log(b); // 2019-02-11T09:28:29-02:00
if you notice the values are equal, execept the last part, where moment gives -08:00
but date-fns-timezone returns -02:00
Metadata
Metadata
Assignees
Labels
No labels