You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PackageHelper/www/assets/js/util.js

30 lines
1.0 KiB
JavaScript

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
function timestampToDateTimeString(timestamp) {
var date = new Date(timestamp * 1000);
var pm = date.getHours() >= 12;
var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours();
hours = (hours == 0 ? 12 : hours);
var minutes = date.getMinutes();
var time = hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + " " + (pm ? "PM" : "AM");
return date.toLocaleDateString() + " " + time;
}
function timestampToTimeString(timestamp) {
var date = new Date(timestamp * 1000);
var pm = date.getHours() >= 12;
var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours();
hours = (hours == 0 ? 12 : hours);
var minutes = date.getMinutes();
var time = hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + " " + (pm ? "PM" : "AM");
return time;
}