美文网首页
js时间戳转年月日时分秒

js时间戳转年月日时分秒

作者: 瓩千瓦 | 来源:发表于2023-02-28 17:45 被阅读0次

js时间戳转年月日时分秒

export function formatDate (value) {
    if (!value) return ''
    if (value !== undefined || value !== '' || value != null) {
        const date = new Date(value);
        const y = date.getFullYear();
        let MM = date.getMonth() + 1;
        MM = MM < 10 ? ('0' + MM) : MM;
        let d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        let h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        let m = date.getMinutes();
        m = m < 10 ? ('0' + m) : m;
        let s = date.getSeconds();
        s = s < 10 ? ('0' + s) : s;
        const time = y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s
        return time;
    }
}

相关文章

  • datetime:时间戳转换

    将时间戳转换为年月日时分秒格式: 将年月日时分秒格式转换为时间戳:

  • jquery将时间戳转为精确到秒的时间

    时间戳 转为年月日 时分秒 时间转为时间戳,或时间戳转为时间

  • UTC时间与时区时间转换

    描述 时间日期与time stamp转换 参考 C语言实现将时间戳转换为年月日时分秒和将年月日时分秒转换为时间戳 ...

  • 【微信小程序】时间戳转换

    本章主要讲时间戳转换成时间,Y/M/D h:m:s(年月日时分秒) 将js代码放到utils文件的utils.js...

  • day19时间模块

    时间模块 主要包含处理年月日时分秒对应的时间(着重时分秒) 专门处理年月日 1.获取当前时间 时间戳:就是从格林威...

  • CocosCreator3.x开发笔记3:时间相关

    秒转换为时分秒 获取时间戳 number转年月日

  • 4.时间的处理,monent插件

    1.格式化时间 2.格式化年月日时分秒 3.通过获取当前时间的时间戳转化为年月日时分秒 4.某个时间时间戳转换成日...

  • 时间公共方法

    时间戳转日期时间 毫秒转时分秒

  • day19time模块

    01-时间模块 模块中主要包含处理年月日时分秒对应的时间(着重时分秒) 专门用来处理年月日 1.获取当前时间时间戳...

  • 19 几个常用库

    1.time模块 主要包含处理年月日时分秒对应的时间(着重时分秒)首先引入时间戳的概念:时间戳就是从格林尼治时间(...

网友评论

      本文标题:js时间戳转年月日时分秒

      本文链接:https://www.haomeiwen.com/subject/sgvlldtx.html