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;
    };
  • 相关阅读:
    Oracle行转列,pivot函数和unpivot函数
    hive中使用spark执行引擎的常用参数
    Spark消费Kafka如何实现精准一次性消费?
    Flink 保证ExactlyOnce
    Flink的容错
    scala实现kafkaProduce1.0读取文件发送到kafka
    flume1.5的几种conf配置
    shell:ps awk杀死进程
    scala的maven项目中的pom文件
    hive开窗函数进阶
  • 原文地址:https://www.cnblogs.com/xiaonangua/p/10728487.html
Copyright © 2011-2022 走看看