function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
var strHours = date.getHours();
var strMinutes = date.getMinutes();
var strSeconds = date.getSeconds();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
if (strHours >= 0 && strHours <= 9) {
strHours = "0" + strHours;
}
if (strMinutes >= 0 && strMinutes <= 9) {
strMinutes = "0" + strMinutes;
}
if (strSeconds >= 0 && strSeconds <= 9) {
strSeconds = "0" + strSeconds;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + strHours + seperator2 + strMinutes
+ seperator2 + strSeconds;
return currentdate;
}
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
var strHours = date.getHours();
var strMinutes = date.getMinutes();
var strSeconds = date.getSeconds();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
if (strHours >= 0 && strHours <= 9) {
strHours = "0" + strHours;
}
if (strMinutes >= 0 && strMinutes <= 9) {
strMinutes = "0" + strMinutes;
}
if (strSeconds >= 0 && strSeconds <= 9) {
strSeconds = "0" + strSeconds;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
+ " " + strHours + seperator2 + strMinutes
+ seperator2 + strSeconds;
return currentdate;
}
本文介绍了一个JavaScript函数,该函数能够返回当前的日期和时间,并将其格式化为易于阅读的形式。具体来说,该函数会获取当前的时间,然后将年、月、日、小时、分钟和秒分别格式化,并使用特定的分隔符连接起来。
&spm=1001.2101.3001.5002&articleId=78270150&d=1&t=3&u=d28ad2e123e84c68836219affc8c8ef3)
6052

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



