function DateUtils(){
this.dataObj = new Date();
this.now = this.dataObj.getFullYear() + "-" +
((this.dataObj.getMonth()+1) > 9 ? (this.dataObj.getMonth()+1) : ("0" + (this.dataObj.getMonth()+1))) + "-" +
(this.dataObj.getDate() > 9 ? this.dataObj.getDate() : ("0" + this.dataObj.getDate()));
this.firstDay = this.dataObj.getFullYear() + "-01-01";
this.getNow = function() {
return this.now;
}
this.getFirstDay = function() {
return this.firstDay;
}
}
var du = new DateUtils();
alert(du.getFirstDay());
alert(du.getNow());
JavaScript 显示当前日期
最新推荐文章于 2023-10-11 00:19:05 发布