We are using moment.js and HighCharts library to plot the data points on the graphs. When we try to plot the data points with other timezone, it is plotting correctly. Where as when we change the timezone to Sao Paulo, it is showing the data points as one hour ahead of the current time. We have updated the moment.js to the latest as of reference with the thread opened at https://github.com/moment/moment-timezone/issues/399. But it was of no help. The code we have used to convert to the user time zone is as follows,
time: {
timezone: $('#user-timezone').val()
},
EDIT: I am sorry, I did not had the latest version of Moment Timezone. I downloaded it from the momentjs.com website, but that is an old version. I downloaded now the latest version (0.5.27) from, Github releases and this fixed our issue.
We also still have this issue after upgrading to the latest version. Sao Paulo time is one hour ahead, probably due to DST.
Example code:
function toTimeZone(utc_date, format){
var zone = 'America/Sao_Paulo';
return moment(utc_date).tz(zone).format(format);
}
function getDateTime(){
var time = moment.utc().format();
return toTimeZone(time, 'L LTS');
}
console.log(getDateTime());
@fazeela-veolia I just tried the latest version and America/Sao_Paulo looks ok
Most helpful comment
@fazeela-veolia I just tried the latest version and America/Sao_Paulo looks ok