• 2020/6.30


    1.'2020-06-29 23:59:59'--> '6.29'

    let res='2020-06-29 23:59:59' //6.29
    let res1=res .slice(5).split(" ")[0].replace("-", ".")
    console.log(res1);

     2.  915998847=> 915,998,847

    const totalServiceTimes=915998847

    3.字符串数字

    const str = '10'
    const res = str * 1 //字符串数字转数字
    
    const num=20
    const res1=''+num //数字转为字符串数字

     4.js获取走动时间

    
    
    created() {
       this.timer = setInterval(this.getTime1, 1000);
    
    
      },


    methods: { getTime1() { const time
    = new Date(); let year = time.getFullYear(); //获取年份 let month = this.padZero(time.getMonth() + 1); //获取月份 let day = this.padZero(time.getDate()); //获取日期 let hour = this.padZero((time.getHours())); //获取时 let minute = this.padZero(time.getMinutes()); //获取分 let second = this.padZero(time.getSeconds()); //获取秒 this.currentTime = `${year}-${month}-${day} ${hour}:${minute}:${second}` }, padZero(num) { return ('' + num).padStart(2,'0') }, }

    5. 9->009->[0 ,0 ,9] ; 41->041->[0 ,4 ,1]

    function PrefixInteger(num, n) {
      let number = num ? (Array(n).join(0) + num).slice(-n) : 0;
      let numArr = String(number)
        .split("")
        .map(it => it * 1);
      return numArr;
    }
    console.log(PrefixInteger(9,3))

     function PrefixInteger(num,n=3){
        return (num+'').padStart(3,'0').split('').map(Number)

      }
  • 相关阅读:
    解决SecureCRT中文显示乱码
    能大大提升工作效率和时间效率的9个重要习惯
    PHP基础知识
    CI学习相关地址
    IE8引入JavaScript
    IE9以下不支持placeholder属性
    IE8浏览器兼容性问题
    简单的DOS命令
    Linux常用运维指令
    log4j日志+面向切面监控异常
  • 原文地址:https://www.cnblogs.com/xiaoliziaaa/p/13212493.html
Copyright © 2020-2023  润新知