date-helper.ts

13 lines | 402 B Blame History Raw Download
export function formatDate(date: string): string {
    if (date == "") {
        return "No date";
    }
    var d = new Date(date);
    return pad(d.getDate()) + "-" + pad(d.getMonth() + 1) + "-" + d.getFullYear() + " " + pad(d.getHours()) + ":" + pad(d.getMinutes());
}

function pad(value: number): string {
    var strVal = value.toString();

    return strVal.length > 1 ? strVal : "0" + strVal;
}