• layui table 时间戳


                    , { field: 'CreateTime',  175, title: '时间', templet: '<div>{{ laytpl.toDateString(d) }}</div>' },

    或者

                  , { field: 'CreateTime',  175, title: '时间', templet: titleTpl },
    <script>
            //时间戳的处理
            var laytpl = function () { };
            laytpl.toDateString = function (d, format) {
                if (d) {
                     var time = d.CreateTime.match(/[^()]+(?=))/)[0];
                }
                time = timestampToTime(time);
                var date = new Date(time || new Date())
                , ymd = [
                  this.digit(date.getFullYear(), 4)
                  , this.digit(date.getMonth() + 1)
                  , this.digit(date.getDate())
                ]
                , hms = [
                  this.digit(date.getHours())
                  , this.digit(date.getMinutes())
                  , this.digit(date.getSeconds())
                ];
    
                format = format || 'yyyy-MM-dd HH:mm:ss';
    
                return format.replace(/yyyy/g, ymd[0])
                .replace(/MM/g, ymd[1])
                .replace(/dd/g, ymd[2])
                .replace(/HH/g, hms[0])
                .replace(/mm/g, hms[1])
                .replace(/ss/g, hms[2]);
            };
    
            //数字前置补零
            laytpl.digit = function (num, length, end) {
                var str = '';
                num = String(num);
                length = length || 2;
                for (var i = num.length; i < length; i++) {
                    str += '0';
                }
                return num < Math.pow(10, length) ? str + (num | 0) : num;
            };
    
        </script>
    
        @*<script type="text/html" id="titleTpl">
                {{#
            var date = new Date();
            date.setTime(d.createTime); //NAN 这里没有小写的createTime
            return d.createTime;
        }}
            </script>
            <script>
                Date.prototype.Format = function (fmt) { //author: meizz
                    var o = {
                        "M+": this.getMonth() + 1,                 //月份
                        "d+": this.getDate(),                    //
                        "h+": this.getHours(),                   //小时
                        "m+": this.getMinutes(),                 //
                        "s+": this.getSeconds(),                 //
                        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                        "S": this.getMilliseconds()             //毫秒
                    };
                    if (/(y+)/.test(fmt))
                        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                    for (var k in o)
                        if (new RegExp("(" + k + ")").test(fmt))
                            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    return fmt;
                }
            </script>*@
        <script id="createTime" type="text/html">
            {{createTime(d.createTime)}}
        </script>
        <script type="text/javascript">
            function timestampToTime(timestamp) {
                var date = new Date(timestamp * 1);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
                Y = date.getFullYear() + '-';
                M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                D = date.getDate() + ' ';
                h = date.getHours() + ':';
                m = date.getMinutes() + ':';
                s = date.getSeconds();
                return Y + M + D + h + m + s;
            }
        </script>
     that_obj.startTime = (new Date).getTime();
  • 相关阅读:
    Spring Boot 创建一个可以执行的 Jar
    Spring Boot 第一个示例启动运行
    Spring Boot 第一个示例 “main” 方法
    Spring Boot 第一个示例 @EnableAutoConfiguration 注解
    Spring Boot 第一个示例的 @RestController 和 @RequestMapping 注解
    Spring Boot 2.4 第一个示例程序书写代码
    Spring Boot 2.4 第一个示例程序添加 Classpath 依赖
    Spring Boot 2.4 示例创建 POM 文件
    Spring Boot 2.4 部署你的第一个 Spring Boot 应用需要的环境
    Mysql 的concat、concat_ws()以及group_concat()的用法与区别
  • 原文地址:https://www.cnblogs.com/enych/p/9232137.html
Copyright © 2020-2023  润新知