{"action":"created","issue":{"url":"https://api.github.com/repos/moment/moment/issues/2250","labels_url":"https://api.github.com/repos/moment/moment/issues/2250/labels{/name}","comments_url":"https://api.github.com/repos/moment/moment/issues/2250/comments","events_url":"https://api.github.com/repos/moment/moment/issues/2250/events","html_url":"https://github.com/moment/moment/issues/2250","id":59589289,"number":2250,"title":"utcOffset() doesn't work as expected","user":{"login":"judepereira","id":747087,"avatar_url":"https://avatars.githubusercontent.com/u/747087?v=3","gravatar_id":"","url":"https://api.github.com/users/judepereira","html_url":"https://github.com/judepereira","followers_url":"https://api.github.com/users/judepereira/followers","following_url":"https://api.github.com/users/judepereira/following{/other_user}","gists_url":"https://api.github.com/users/judepereira/gists{/gist_id}","starred_url":"https://api.github.com/users/judepereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/judepereira/subscriptions","organizations_url":"https://api.github.com/users/judepereira/orgs","repos_url":"https://api.github.com/users/judepereira/repos","events_url":"https://api.github.com/users/judepereira/events{/privacy}","received_events_url":"https://api.github.com/users/judepereira/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-03T03:19:04Z","updated_at":"2015-03-04T21:34:58Z","closed_at":null,"body":"When I explicitly set the UTC offset using utcOffset(), I expect that the epoch returned should be the same across different timezones. However, here's what I've observed:\r\n\r\n**In some Canadian timezone:**\r\nmoment(\"20150303\", \"YYYYMMDD\").utcOffset(__TIMEZONE_OFFSET_MINUTES).unix()\r\n**1425362400**\r\n\r\n**In IST:**\r\nmoment(\"20150303\", \"YYYYMMDD\").utcOffset(__TIMEZONE_OFFSET_MINUTES).unix()\r\n**1425321000**\r\n\r\n*__TIMEZONE_OFFSET_MINUTES is 330 (IST) in both cases.*\r\n\r\nHow can I get the same epoch in both cases? 1425321000 is the expected one."},"comment":{"url":"https://api.github.com/repos/moment/moment/issues/comments/77254211","html_url":"https://github.com/moment/moment/issues/2250#issuecomment-77254211","issue_url":"https://api.github.com/repos/moment/moment/issues/2250","id":77254211,"user":{"login":"mj1856","id":1396388,"avatar_url":"https://avatars.githubusercontent.com/u/1396388?v=3","gravatar_id":"","url":"https://api.github.com/users/mj1856","html_url":"https://github.com/mj1856","followers_url":"https://api.github.com/users/mj1856/followers","following_url":"https://api.github.com/users/mj1856/following{/other_user}","gists_url":"https://api.github.com/users/mj1856/gists{/gist_id}","starred_url":"https://api.github.com/users/mj1856/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mj1856/subscriptions","organizations_url":"https://api.github.com/users/mj1856/orgs","repos_url":"https://api.github.com/users/mj1856/repos","events_url":"https://api.github.com/users/mj1856/events{/privacy}","received_events_url":"https://api.github.com/users/mj1856/received_events","type":"User","site_admin":false},"created_at":"2015-03-04T21:34:58Z","updated_at":"2015-03-04T21:34:58Z","body":"This is the expected behavior.\r\n\r\nCalling `utcOffset` or `zone` only shifts the time zone offset that you see when you *output* values from the moment object.  It doesn't change the way moment processes the *input*.  Since you are calling `moment(\"20150303\", \"YYYYMMDD\")` in both cases, it has the same behavior in both cases - which is to interpret the value in the *local* time zone.  When the local time zone is different, you get two different moments on the instantaneous timeline.\r\n\r\nIf you want the input value to always be interpreted as IST, you should include the zone offset in the input string.\r\n\r\n    moment(\"20150303+0530\", \"YYYYMMDDZZ\")\r\n\r\nThis will still use the local time zone for output, but that doesn't matter for `.unix`, as that function aligns to UTC.  If you needed both input and output to align (for other purposes), then use the `parseZone` method:\r\n\r\n    moment.parseZone(\"20150303+0530\", \"YYYYMMDDZZ\")\r\n\r\nBut what if you only have the offset as a number of whole minutes instead of a `+hhmm` string?  Then do this:\r\n\r\n    var offset = 330;\r\n    moment.utc(\"20150303\", \"YYYYMMDD\").subtract(offset,'minutes').utcOffset(offset)"}}