0

I am doing a simple test (i'm located in France) using moment and moment-timezone (with moment Angular2 libraries).

I'm not succeeding at getting logical results despite whats in the docs.

let timezone = moment.tz.guess();
console.log(timezone); // ok: Europe/Paris

let now = moment();
let nowFr = now.tz(timezone); // docs: should convert to time zone

// both display UTC format (13pm instead of 15pm local time)
console.log(now.toISOString());
console.log(nowFr.toISOString());

// first show 13pm, second 15pm
// this works, but i'm supposed to be passing ISO string to Ionic2 date picker !!
console.log(now.format());
console.log(nowFr.format());
Romain Bruckert
  • 2,546
  • 31
  • 50
  • 1
    Possible duplicate of [Locale time on IONIC2 Datetime picker](https://stackoverflow.com/questions/39611380/locale-time-on-ionic2-datetime-picker) – Romain Bruckert Jun 12 '17 at 13:51
  • 1
    As the [docs](http://momentjs.com/docs/#/displaying/as-iso-string/) says: _`.toISOString()` always returns a timestamp in UTC_, for this reason your code prints 13 (France is 2 hours ahead UTC) – VincenzoC Jun 12 '17 at 14:02

0 Answers0