function curentTime()
{
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ddate= year + "-";
if(month < 10)
ddate+= "0";
ddate+= month + "-";
if(day < 10)
ddate+= "0";
ddate+= day + " ";
if(hh < 10)
ddate+= "0";
ddate+= hh + ":";
if (mm < 10) ddate+= '0';
ddate+= mm;
return(ddate);
}
本文介绍了一个简单的JavaScript函数,用于获取当前的日期和时间,并以特定的格式返回。该函数利用了JavaScript内置的Date对象来实现日期时间的获取与格式化。
966

被折叠的 条评论
为什么被折叠?



