/* * 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; }