重庆熊猫 Loading

JavasScript打印年月日时间代码

就是Date的API,直接上代码啦。

//打印中文的日期
function printChineseDateTime()
{
    var now=new Date();
    var str = now.getFullYear()+"年"
		+(now.getMonth()+1)+"月"
		+now.getDate()+"日"
		+now.getHours()+"时"
		+now.getMinutes()+"分"
		+now.getSeconds()+"秒";

    return str;
}

//test
console.log(printChineseDateTime());
posted @ 2022-05-21 16:56  重庆熊猫  阅读(119)  评论(0编辑  收藏  举报