i have a date string on NodeJS
2019-02-25T09:00:00Z
I create a moment object, and set the timezone to new york
let a = moment.tz("2019-02-25T09:00:00Z", "America/New_York");
I then create another moment object, with the same time, but set a different place, arizona
let b = moment.tz("2019-02-25T09:00:00Z", "America/Phoenix");
console.log(a.diff(b));
prints out 0 milliseconds. i would expect expect to get 7200000 (2 hour time difference). why am i not getting this difference?
"2019-02-25T09:00:00Z" means "9am on February 25th 2019, UTC". The "Z" part is what indicates that the value is in UTC.
You've created two values representing the same instant in time, but in two different time zones - so they'll have different local values, but they both represent the same instant, so the difference between them is 0.
If you want to create a value which represents "9am on February 25th 2019, in the given time zone" then just remove the Z. (I don't know what Moment does if the value you specify is either ambiguous or skipped due to offset changes in the time zone, but that's something you should investigate if you're going to do this with arbitrary data.)