发布网友 发布时间:2022-04-20 14:56
共2个回答
热心网友 时间:2022-04-23 14:09
<SCRIPT LANGUAGE="JavaScript">热心网友 时间:2022-04-23 15:27
//获取当前日期yyyy-MM-dd
function getNowFormatDate() {
var date = new Date();
var seperator1 = "-";
//var seperator2 = ":";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
}
//获取当前日期yyyy-MM-dd HH:mm:ss
function getNowFormatDate1() {
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate
+ " " + date.getHours() + seperator2 + date.getMinutes()
+ seperator2 + date.getSeconds();
return currentdate;
}