dreamsails
//得到当前日期
formatterDate = function (date) {
    var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
    var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
        + (date.getMonth() + 1);
    return date.getFullYear() + \'-\' + month + \'-\' + day;
};

//显示当前日期带时分秒
formatterDateAll = function (date) {
    var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
    var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0"
        + (date.getMonth() + 1);
    var hor = date.getHours();
    var min = date.getMinutes();
    var sec = date.getSeconds();
    return date.getFullYear() + \'-\' + month + \'-\' + day + " " + hor + ":" + min + ":" + sec;
};

//调用
formatterDate(new Date());

分类:

技术点:

相关文章:

  • 2022-01-13
  • 2021-11-30
  • 2022-01-01
  • 2021-10-19
  • 2021-06-01
  • 2021-12-18
猜你喜欢
  • 2022-01-11
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案