Parsing date using timezone returns different output if used with and without date format.
Current result:
moment.tz("18 Oct 2019, 15:40:42", "Europe/London").valueOf()
1571413242000
moment.tz("18 Oct 2019, 15:40:42", "DD MMM YYYY, hh:mm:ss", "Europe/London").valueOf()
1571409642000
Expected result:
moment.tz("18 Oct 2019, 15:40:42", "Europe/London").valueOf()
1571409642000
moment.tz("18 Oct 2019, 15:40:42", "DD MMM YYYY, hh:mm:ss", "Europe/London").valueOf()
1571409642000
This does not look like expected behaviour.
Result of converting date based on timezone should not be dependent on date formatting.
The problem is that moment-timezone only accepts auto parse for RFC2822 or ISO format.
var moment1 = moment.tz("2019-10-18T15:40:42", "America/New_York").valueOf();
var moment2 = moment.tz("18 Oct 2019, 15:40:42", "DD MMM YYYY, hh:mm:ss", "America/New_York").valueOf();
This is the same bug as https://github.com/moment/moment-timezone/issues/807 - @todo fix it
Most helpful comment
The problem is that moment-timezone only accepts auto parse for RFC2822 or ISO format.
var moment1 = moment.tz("2019-10-18T15:40:42", "America/New_York").valueOf();var moment2 = moment.tz("18 Oct 2019, 15:40:42", "DD MMM YYYY, hh:mm:ss", "America/New_York").valueOf();