<span style="font-size:18px;">//创建日期默认为当日 onload="javascript:initDate();"
function initDate(){
var date = new Date();
var seperator1 = "-";
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;
$("#createDate").val(currentdate);
} </span>jsp页面通过js将时间格式化并赋初始值
最新推荐文章于 2021-10-21 11:18:11 发布
本文介绍了一个使用JavaScript实现的简单函数,该函数可以自动获取当前日期并将其格式化为年-月-日的形式。通过这个函数,用户可以在网页或其他JavaScript应用中轻松地显示标准化的日期。
1005

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



