Interestingly the date timezone conversion appears to be done automaetically. Messages coming from the server are stamped with a 4 digit offset (eg: <message id="223493" dateTime="Sun, 10 Apr 2016 16:22:24 +0000" ... for UTC )
Javscript then takes that string in the constructor for the Date object and converts it to your browser's time automagically. Something I didn't know was a thing.
I can't find a clean way to make javascript ignore the offset, but one option is to add/subtract the right amount from the date before displaying it. You can get the offset in minutes with getTimezoneOffset, then convert that to seconds and create a new date with that number of seconds added to it.
var dateObj = new Date(dateObj.getTime() + dateObj.getTimezoneOffset()*60000);
So in your custom.js you would add this:
ajaxChat.formatDate = (format, date) {
date = (date === null) ? new date() : date;
date = new Date(date.getTime() + date.getTimezoneOffset()*60000);
return format
.replace(/%Y/g, date.getFullYear())
.replace(/%m/g, this.addLeadingZero(date.getMonth()+1))
.replace(/%d/g, this.addLeadingZero(date.getDate()))
.replace(/%H/g, this.addLeadingZero(date.getHours()))
.replace(/%i/g, this.addLeadingZero(date.getMinutes()))
.replace(/%s/g, this.addLeadingZero(date.getSeconds()));
}
And be sure to clear your cache or do a hard refresh to see the changes. All I've added there is one line to reset the date.
Another solution is to just ask specifically for the UTC minutes and hours (and month, and date, and seconds, I guess).
ajaxChat.formatDate = (format, date) {
date = (date === null) ? new date() : date;
return format
.replace(/%Y/g, date.getFullYear())
.replace(/%m/g, this.addLeadingZero(date.getUTCMonth()+1))
.replace(/%d/g, this.addLeadingZero(date.getUTCDate()))
.replace(/%H/g, this.addLeadingZero(date.getUTCHours()))
.replace(/%i/g, this.addLeadingZero(date.getUTCMinutes()))
.replace(/%s/g, this.addLeadingZero(date.getUTCSeconds()));
}