zoukankan      html  css  js  c++  java
  • 简易版时间封装

    封装一个时间戳

    主要应用:更新博客,评论等尾部带时间

    function dateStr(d,sign){
    if(!sign){
    sign='-'
    }else{
    sign = sign;
    }
    let year = d.getFullYear(),
    month = d.getMonth()+1,
    day = d.getDate(),
    hours = d.getHours(),
    minutes = d.getMinutes(),
    seconds = d.getSeconds();
    return year + sign + mendZero(month) + sign + mendZero(day) 
    + mendZero(hours)+sign + mendZero(minutes) + sign + mendZero(seconds);

    }
     
    字符串补零 
    function mendZero(num){
    return num = num < 10 ? '0' + num : num;
    }
     
  • 相关阅读:
    meta标签
    Vue(day8)
    Vue(day7)
    Vue(day6)
    Flex布局
    Vue(day5)
    jquery.data()&jquery.extend()
    Promise对象
    Vue(day4)
    Vue(day3)
  • 原文地址:https://www.cnblogs.com/sunny-yu/p/11353989.html
Copyright © 2011-2022 走看看