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;
    }

  • 相关阅读:
    iOS开发UI篇—字典转模型
    使用python编写批量卸载android应用的脚本
    CircularProgressBar
    Custom-Progress-Dialog-Android
    picasso jar
    swift
    Python编程
    H264分析工具
    Android Websites
    AnATools
  • 原文地址:https://www.cnblogs.com/liwp/p/5664937.html
Copyright © 2011-2022 走看看