zoukankan      html  css  js  c++  java
  • 一个随时更新的js库

    1.src同级建commFunction=》timer.js

    2.main.js引入

    import time from '../commonFunction/time'
    Vue.prototype.time=time
    =======================================

    情况一1.时间戳

    // 时间戳转时间 2020-4-24 00:30:00
        timeStamp(val) {
            val = val.toString()
            if(val.length == 10) {
              let time = val * 1000;
              let timestamp4 = new Date(time);
              return (timestamp4.toLocaleDateString().replace(///g, "-") +" " + timestamp4.toTimeString().substr(0, 8));
            } else {
              let timestamp4 = new Date(val);
              return (timestamp4.toLocaleDateString().replace(///g, "-") +" " +timestamp4.toTimeString().substr(0, 8));
            }
        },
        // 2017-4-8 14:11:33转2017-04-08 14:11:33
        handeldate(m){
            let o = m[0]+m[1]+m[2]+m[3]
            if(m.length==18){
                if(m[6]=='-'){
                    return o+m[4]+'0'+m[5]+m[6]+m[7]+m[8]+m.slice(9)
                }
                if(m[7]=='-'){
                    return o+m[4]+m[5]+m[6]+m[7]+'0'+m[8]+m.slice(9)
                }
            }else if(m.length==17){
                return o+m[4]+'0'+m[5]+m[6]+'0'+m[7]+m.slice(8)
            }else{
                return m
            }
        }
    页面使用:
    appList.forEach(element => {
                  element.create_time = this.time.handeldate(this.time.timeStamp(element.create_time))
                });
  • 相关阅读:
    vagrant 入门3
    vagrant 入门4
    vagrant 入门2
    Map、Debug追踪
    Comparator比较器 、Comparable接口
    File类
    Lambda表达式、函数式编程思想概述
    异常--异常体系、异常的处理、异常的捕获、finally语句块和自定义异常
    List集合、Set集合、Collection集合工具类
    数据结构---栈、队列、数组、链表和红黑树
  • 原文地址:https://www.cnblogs.com/wd163/p/13213773.html
Copyright © 2011-2022 走看看