javascript - How to quickly convert CST time into timestamp
女神的闺蜜爱上我
女神的闺蜜爱上我 2017-06-26 10:53:32
0
1
964
Thu Jun 15 2017 14:35:48 GMT+0800 (CST)

For example, for a time like this, I am currently using the VUE element plug-in. I don’t know why the time comes out in this format. Is there a simpler conversion method?

女神的闺蜜爱上我
女神的闺蜜爱上我

reply all(1)
学习ing

new Date('Thu Jun 15 2017 14:35:48 GMT+0800 (CST)').getTime()
Attach a function

function parseTime (timeStamp, format) {
    var date = new Date(timeStamp);
    var o = {
        'M+' : date.getMonth() + 1, //month
        'D+' : date.getDate(), //day
        'h+' : date.getHours(), //hour
        'm+' : date.getMinutes(), //minute
        's+' : date.getSeconds(), //second
        'S' : date.getMilliseconds() //millisecond
    }

    if(/(Y+)/.test(format)) {
        format = format.replace(RegExp.,
            (date.getFullYear() + '').substr(4 - RegExp..length));
    }

    for(var k in o) {
        if (new RegExp('('+ k +')').test(format)) {
            format = format.replace(RegExp.,
                RegExp..length == 1 ? o[k] : ('00'+ o[k]).substr((''+ o[k]).length));
        }
    }
    return format;
}
// usage
parseTime(new Date.getTime(), 'hh:mm')
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template