zoukankan      html  css  js  c++  java
  • 时间js转换方法Date("149...") 转成 2016-7-12 21:23:34 009

     function timeFormatter(value) {
        var da = new Date(parseInt(value.replace("/Date(", "").replace(")/" , "").split( "+")[0]));
        return da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate();
    //     + " " + da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds();
    }
     
     
     
    //多种返回格式

    function getDate(tm,type) {

    var needdate = "";
    var date = new Date();
    if (tm) {
    date = new Date(parseInt(tm.replace("/Date(", "").replace(")/", "").split("+")[0]));
    }

    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hours = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();
    if (month >= 1 && month <= 9) {
    month = "0" + month;
    }
    if (day >= 1 && day <= 9) {
    day = "0" + day;
    }

    if (minutes >= 1 && minutes <= 9) {
    minutes = "0" + minutes;
    }
    if (hours >= 1 && hours <= 9) {
    hours = "0" + hours;
    }
    if (seconds >= 1 && seconds <= 9) {
    seconds = "0" + seconds;
    }


    if (type == '2')
    {
    needdate = hours + ':' + minutes + ':' + seconds;
    } else {
    needdate = year + '-' + month + '-' + day;
    }
    return needdate;
    }

  • 相关阅读:
    Jetson TX1使用usb camera采集图像 (2)
    Jetson TX1安装pyTorch
    Jetson TX1 install Opencv3
    Jetson TX1使用usb camera采集图像 (1)
    win10双系统安装卸载ubuntu
    弱监督下的目标检测算法
    javascript高级程序设计读书笔记
    好用的linux命令
    正则表达式学习
    yii执行原理
  • 原文地址:https://www.cnblogs.com/liwp/p/5664937.html
Copyright © 2011-2022 走看看