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)
     
  • 相关阅读:
    mysql把查询结果集插入到表理
    js遍历json数据
    php事务回滚
    win10定时执行php脚本
    php输出json的内容
    图像的几个基本概念
    linux系统编程之I/O内核数据结构
    linux系统编程之错误处理
    深拷贝和浅拷贝
    mysql用户的创建
  • 原文地址:https://www.cnblogs.com/zhukaixin/p/14110124.html
Copyright © 2011-2022 走看看