zoukankan      html  css  js  c++  java
  • JS时间戳转时间格式

        //转化为时间格式
        function getDate(timestamp) {
            timestamp = timestamp.replace("/Date(", "").replace(")/", "");
            if (timestamp.indexOf("+") > 0) {
                timestamp = timestamp.substring(0, timestamp.indexOf("+"));
            }
            else if (timestamp.indexOf("-") > 0) {
                timestamp = timestamp.substring(0, timestamp.indexOf("-"));
            }
            let date = new Date(parseInt(timestamp, 10));
            let year = date.getFullYear();
            let month = date.getMonth() + 1 < 10 ? /*"0" +*/ (date.getMonth() + 1) : date.getMonth() + 1;
            let currentDate =( date.getDate() < 10 ? /*"0" + */date.getDate() : date.getDate())+" ";
            let Hours = date.getHours() < 10 ? /*"0" + */date.getHours() : date.getHours();
            let Minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
            let Seconds = date.getSeconds() < 10 ? /*"0" +*/ date.getSeconds() : date.getSeconds();
            return `${year}年${month}月${currentDate}日${Hours}:${Minutes}:${Seconds}`;
        }

    网上找了好多都不行。。。

  • 相关阅读:
    ContentProvider
    铃声设置
    TTS技术
    http://www.w3cschool.cc/jqueryui/jqueryui-tutorial.html
    HttpHelper
    .net面试题
    函数和原型
    关于递增运算符
    CSS学习笔记
    CSS/CSS3 如何实现元素水平居中
  • 原文地址:https://www.cnblogs.com/heheblog/p/10424830.html
Copyright © 2011-2022 走看看