JavaScript setDate () method
Definition and Usage
setDate () method is used to set one day a month.
Browser Support
All major browsers support setDate () method
grammar
Date.setDate( day )
Parameter Value
参数 | 描述 |
---|---|
day | 必需。
表示一个月中的一天的一个数值(1 ~ 31):
如果当月有 31 天:
如果当月有 30 天:
|
return value
Type | 描述 |
---|---|
Number | 1970年1月1日午夜至调整过日期的毫秒数。在 ECMAScript 标准化之前,该方法什么都不返回。 |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
Set one day a month for the last day of the last month:
var d = new Date();
d.setDate(0);
d.setDate(0);
d output:
try it"
Examples
In this example, we will () method to set the day of the current month by setDate 15:
var d = new Date("July 21, 1983 01:15:00");
d.setDate(15);
d.setDate(15);
d output:
try it"