Js timestamp conversion

the string 1542274800000 passed from the background, how to convert it to time format

Nov.19,2021


Date.prototype.Format = function (fmt) {
    var o = {
            "M+": this.getMonth() + 1, // 
            "d+": this.getDate(), // 
            "h+": this.getHours(), // 
            "m+": this.getMinutes(), // 
            "s+": this.getSeconds(), // 
            "q+": Math.floor((this.getMonth() + 3) / 3), // 
            "S": this.getMilliseconds() // 
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + ""));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
new Date(1542274800000).Format('yy-MM-dd hh:mm:ss'); //"2018-11-15 17:40:00"

javascript timestamp changes to date-time custom format, supporting multiple combinations of year, month, week, day, hour, minute and second

< H2 > example < / H2 >
year, month, day, hour, minute, second
  

moment.js
you can change to whatever format you want

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e58872-279f4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e58872-279f4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?