How js/jquery parses the timestamp to the specified format

clipboard.png

,

clipboard.png

I want to convert to

in yyyy-MM-dd HH:mm:ss format.
Mar.21,2021

use the library, date-fns or moment

or there is an old piece of code that extends the Date object

directly.
Date.prototype.format = function(format = "yyyy-MM-dd") {
    var o = {
        //month 
        "M+": this.getMonth() + 1,
        // day  + 1
        "d+": this.getDate(),
        // hour 24
        "H+": this.getHours(),
        // 12
        "h+": this.getHours() % 12,
        // minute 
        "m+": this.getMinutes(),
        // second 
        "s+": this.getSeconds(),
        // quarter 
        "q+": Math.floor((this.getMonth() + 3) / 3),
        // millisecond 
        "S": this.getMilliseconds()
    };

    if (/(y+)/i.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }

    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
};
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-1b338c5-2be9c.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-1b338c5-2be9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?