zoukankan      html  css  js  c++  java
  • javascript常用的方法

    //日期格式化

    format (data, fmt) { // author: meizz
    var o = {
    'M+': data.getMonth() + 1, // 月份
    'd+': data.getDate(), // 日
    'h+': data.getHours(), // 小时
    'm+': data.getMinutes(), // 分
    's+': data.getSeconds(), // 秒
    'q+': Math.floor((data.getMonth() + 3) / 3), // 季度
    'S': data.getMilliseconds() // 毫秒
    }
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (data.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
    },
    getDate () {
    let date = new Date()
    return this.format(date, 'yyyy-MM-dd hh:mm:ss')
    }

    //当前日期加多少天

    getDate (AddDayCount) {
    let date = new Date()
    date.setDate(date.getDate() + AddDayCount)// 获取AddDayCount天后的日期
    let y = date.getFullYear()
    let m = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)// 获取当前月份的日期,不足10补0
    let d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()// 获取当前几号,不足10补0
    let h = date.getHours()// 获取当前小时
    let t = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()// 获取当前分钟,不足10补0
    let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()// 获取当前秒数,不足10补0
    return y + '-' + m + '-' + d + ' ' + h + ':' + t + ':' + s
    }

    //解决大数浮点数
    https://github.com/dt-fe/number-precision
  • 相关阅读:
    浅析跨域请求
    python虚拟环境--virtualenv
    centos7下使用yum安装pip
    centos下python安装与虚拟环境配置
    ES6基础语法
    CCI_chapter 19 Moderate
    CCI_chapter 16 Low level
    CCI_chapter 13C++
    CCI_chapter 8 Recurision
    LeetCode_Generate Parentheses
  • 原文地址:https://www.cnblogs.com/cxdxm/p/6807008.html
Copyright © 2011-2022 走看看