Skip to content

时间戳转换时间格式 #45

@SevenChan07

Description

@SevenChan07

使用toJSON()方法。

// Tue Aug 13 2019 14:27:30 GMT+0800 (中国标准时间)
function time(time = +new Date()) {
    var date = new Date(time + 8 * 3600 * 1000);
    return date.toJSON().substr(0, 19).replace('T', ' ').replace(/-/g, '.');
}

// 2019-08-13T06:27:30.982Z"
time()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions