Anyone knows how can I specify a city to calculate DST in Moment.js?
Because in Brazil some cities change the DST rule so I can't use the detault TimeZone to calculate it.
My work is get a Date and a city that the user select, and I need to calculte de UTC Date. I'm going to do for all countries, but in Brazil I know this issue, so I want to know if there is a way to do that.
You will need the moment-timezone plugin.
For example:
moment.tz("2014-10-01 12:00:00", "America/Sao_Paulo").utc().format("YYYY-MM-DD HH:mm:ss")
Or:
moment.tz("2014-10-01 12:00:00", "America/Sao_Paulo").toISOString()
Keep in mind that Brazil has multiple time zones. It's invalid to ask for "the time in Brazil" - you have to know where in Brazil to get an accurate answer. This Wikipedia entry describes Brazil's time zones in detail, and has a table that lists the corresponding TZ identifiers.
Also, make sure you supply a date and a time - not just a date. Otherwise, the conversion to UTC is meaningless.