zoukankan      html  css  js  c++  java
  • /Date(1555554794000)/ 转换为日期格式

     第一种方法

    /Date(1555554794000)/ 转换为 2019/4/18

    new Date(parseInt('/Date(1555554794000)/'.substr(6, 13))).toLocaleDateString();

    /Date(1555554794000)/ 转换为 2019/4/18 上午10:33:14

    new Date(parseInt('/Date(1555554794000)/'.substr(6, 13))).toLocaleString()

    /Date(1555554794000)/ 转换为 上午10:33:14

    new Date(parseInt('/Date(1555554794000)/'.substr(6, 13))).toLocaleTimeString()

     第二种方法

    //日期格式化
    function ChangeDateFormat(jsondate) {
        jsondate = jsondate.replace("/Date(", "").replace(")/", "");
        if (jsondate.indexOf("+") > 0) {
            jsondate = jsondate.substring(0, jsondate.indexOf("+"));
        }
        else if (jsondate.indexOf("-") > 0) {
            jsondate = jsondate.substring(0, jsondate.indexOf("-"));
        }
        var date = new Date(parseInt(jsondate, 10));
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
        var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
        var second = date.getMilliseconds() / 1000 < 10 ? "0" + parseInt(date.getMilliseconds() / 1000) : parseInt(date.getMilliseconds() / 1000);
        return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + second;
    };
  • 相关阅读:
    应用服务器安装
    datasnap的线程池
    压缩OLEVARIANT数据
    服务端日志记录
    提交主从表的多个已经修改的数据
    MySQL与PostgreSQL相比哪个更好?
    Vue入门常用指令详解
    Laravel模型事件的实现原理详解
    Git 遇到了 early EOF indexpack failed 问题
    Laravel 代码开发最佳实践
  • 原文地址:https://www.cnblogs.com/xiaonangua/p/10728487.html
Copyright © 2011-2022 走看看