zoukankan      html  css  js  c++  java
  • 时间处理函数

     // 时间转换
        function parseDateTime(num) {
            if (!!!num) {
                return "";
            }
            //最后的消息时间
            var date = new Date(+num);
            //console.log(date)
            //当前时间
            var nowDate = new Date();
            //今日零点时间
            var nowDay = new Date(nowDate.getFullYear() + "-" + (+nowDate.getMonth() + 1) + "-" + nowDate.getDate());
    
            var hms = date.getHours() + ":" + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":" + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
            if (date.getTime() >= nowDay.getTime()) {
                return hms;
            }
            if (nowDay.getTime() - 1000 * 60 * 60 * 24 <= date.getTime()) {
                // return $L("yesterday") + " " + hms;
                return '昨天' + " " + hms;
            }
            var month = (+date.getMonth() + 1) < 10 ? "0" + (+date.getMonth() + 1) : (+date.getMonth() + 1);
            var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            if (date.getFullYear() == nowDate.getFullYear()) {
                return month + "-" + day + " " + hms;
            }
            return (date.getFullYear() + "").substr(2, 4) + "-" + month + "-" + day + " " + hms;
    
        };
  • 相关阅读:
    Luncence .Net 使用
    Quartz 使用
    asp.net mvc 部分视图加载区别
    C学习笔记-内存管理
    C学习笔记-内存管理
    C学习笔记-结构体
    C学习笔记-结构体
    C学习笔记-指针
    C学习笔记-指针
    dll的封装和使用
  • 原文地址:https://www.cnblogs.com/yangsg/p/11126532.html
Copyright © 2011-2022 走看看