美文网首页javascript
js时间格式化(1)

js时间格式化(1)

作者: better1534 | 来源:发表于2017-12-07 17:55 被阅读0次

获得时间的格式:12-25 00:00:00

function time_format(time){

        var date = new Date(time);

         M = date.getMonth()+1;

        d = date.getDate();

        h = date.getHours();

        m = date.getMinutes();

        s = date.getSeconds();

        M = M > 9 ? M  :'0'+M;

        d = d > 9 ? d : '0'+d;

        h = h > 9 ? h : '0'+h;

        m = m > 9 ? m : '0'+m;

        s = s > 9 ? s : '0'+s;

        time = M + '-' + d + ' ' +  h + '-' + m + '-' + s;

    return time;

}

相关文章

  • js 实现时间格式化

    js 实现时间格式化 1.导入js包 2.js中用法1.moment(需要格式的时间字符串).format('YY...

  • js时间格式化

    js时间格式化代码贴上:

  • formatDate

    后台返回时间格式化 1、import {formatDate} from '@comJs/data.js' 2、 ...

  • JS时间戳与格式化时间互转

    JS时间戳与格式化时间互转 Javascript 获取当前时间戳(毫秒级别) 时间戳转成格式化时间 格式化时间转成...

  • js时间格式化(1)

    获得时间的格式:12-25 00:00:00 function time_format(time){ var da...

  • js时间戳与字符串转换

    1.日期字符串转时间戳 2.时间戳转换时间 js日期时间格式化,可直接复制打包成js文件使用

  • 时间转换函数moment.js

    moment.js是一款转换时间的插件 安装方式为: 其常用的格式化参数如下表所示: 常用的转换 1.时间格式化 ...

  • 前端时间格式2020-02-11T12:24:18.000+00

    1.公共js 2.在页面中引入1的公共js 3.使用页面中使用转化时间格式化 结构中的写法

  • js时间格式化

    照抄element-ui的时间格式化,将当前时间或者自定义时间格式化为自己需要的格式 dateFormat.js ...

  • js日期格式化

    js时间戳日期格式化 mongo脚本写法 字符串转时间戳

网友评论

    本文标题:js时间格式化(1)

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