dates are now stored in UTC and displayed in local time

This commit is contained in:
azivner
2017-09-30 22:35:13 -04:00
parent 569f7a392d
commit d0cc5f4a5f
8 changed files with 31 additions and 11 deletions

View File

@@ -15,6 +15,16 @@ $(document).bind('keydown', 'alt+s', function() {
$("input[name=search]").focus();
});
function getDateFromTS(timestamp) {
// Date accepts number of milliseconds since epoch so UTC timestamp works without any extra handling
// see https://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript
const utcDate = new Date(timestamp * 1000);
const localDate = new Date(utcDate.getTime() - utcDate.getTimezoneOffset() * 60 * 1000);
return localDate;
}
function formatTime(date) {
return (date.getHours() <= 9 ? "0" : "") + date.getHours() + ":" + (date.getMinutes() <= 9 ? "0" : "") + date.getMinutes();
}