UTC Server Date Timezone conversion on Browser
Got some issues converting date from the server to the timezone of the user viewing it. You can imagine displaying date and time from the server and the user can not see it interpreted in his/her own timezone. I solved this on a project and would like to share my solution so I can save someone from stress. Below is the javascript to use.
function timezoneConverter(mydate){
var d = new Date(mydate);
d.setUTCFullYear(d.getFullYear());
d.setUTCMonth(d.getMonth());
d.setUTCDate(d.getDate());
d.setUTCHours(d.getHours());
d.setUTCMinutes(d.getMinutes());
d.setUTCSeconds(d.getSeconds());
return d;
}
Make sure your date is a valid date in Java Script. You might like to format your date, you can use momentjs for that. Hope this helped someone.