JS获取当前日期
发布日期:2021-05-10 23:59:28 浏览次数:10 分类:精选文章

本文共 1582 字,大约阅读时间需要 5 分钟。

���������JS���������������������

���JavaScript���������������������������������������������Date���������������������Date()������������������������������������������������������������������������������������

������������������������������������������������������������

  • ���������������������getFullYear()������������������������������
  • ���������������getMonth()������������1-12���������������JavaScript���������0������������������������������1������������������������
  • ���������������������getDate()������������������������
  • ���������������getHours()���getMinutes()���getSeconds()������������������������������������
  • ���������������

    // ������������������const now = new Date();const timeString = `${now.getFullYear()}-${(now.getMonth() + 1)}-${now.getDate()}`;console.log(timeString); // ���������������2024-03-20

    ���������������������������������������������setInterval������������������������������������������������������������

    const cc = function() {    const now = new Date();    document.getElementById('time').textContent = `        ${now.getFullYear()}-${(now.getMonth() + 1)}-${now.getDate()}         ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}    `;};// ������������������������setInterval(cc, 1000);

    ������������������

    • Date���������������������������������������������
    • ���������������������setInterval���������setTimeout���
      ������������setInterval���������������������������������������������������������setTimeout���������������������

    ������������������������������������������������������������������������������������������������������������������������������

    上一篇:JQury实现轮播图
    下一篇:表格与form表单

    发表评论

    最新留言

    哈哈,博客排版真的漂亮呢~
    [***.90.31.176]2025年04月05日 18时02分46秒