zoukankan      html  css  js  c++  java
  • 前端 时间转换为时间戳 时间戳转时间

     时间戳转时间 

    /**
    使用方法:
    this.endValue = this.dataFormat(resultEnd, "Y-m-d H:i:s")
    */

    dataFormat(timestamp, formats) {
    // formats格式包括 // 1. Y-m-d // 2. Y-m-d H:i:s // 3. Y年m月d日 // 4. Y年m月d日 H时i分 formats = formats || 'Y-m-d'; let zero = function (value) { if (value < 10) { return '0' + value; } return value; }; let myDate = timestamp ? new Date(timestamp) : new Date(); let year = myDate.getFullYear(); let month = zero(myDate.getMonth() + 1); let day = zero(myDate.getDate()); let hour = zero(myDate.getHours()); let minite = zero(myDate.getMinutes()); let second = zero(myDate.getSeconds()); return formats.replace(/Y|m|d|H|i|s/ig, function (matches) { return ({ Y: year, m: month, d: day, H: hour, i: minite, s: second })[matches]; }); }

    时间转换为时间戳

     
    /**
    当前时间转为时间戳
    */
    let myDate = new Date(); let time = myDate.getFullYear() + '/' + (myDate.getMonth() + 1) + '/' + (myDate.getDate()) + ' ' + myDate.getHours() + ':' + myDate.getMinutes() + ':' + myDate.getSeconds(); let resultStart = Date.parse(time) - (28 * 3600000)
     
  • 相关阅读:
    迷宫最短路问题
    回溯算法
    解题报告:poj1321 棋盘问题
    矩阵、分数、点、线类
    判断图像中有多少行文本(开发中)
    图形-回行扫描函数
    贝叶斯分类器
    js解析数学运算公式
    用postcss给less加上webkit前缀
    node创建文件夹
  • 原文地址:https://www.cnblogs.com/zhukaixin/p/14110124.html
Copyright © 2011-2022 走看看