--- title: Date.prototype.getDate() slug: Web/JavaScript/Reference/Global_Objects/Date/getDate translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate ---
{{JSRef("Global_Objects", "Date")}}
根据本地时间,返回一个指定的日期对象为一个月中的哪一日(从1--31)。
dateObj.getDate()
无
getDate()
返回一个1 到 31的整数值。
方法
下面第二条语句将值25赋给 day 变量,该值基于日期对象 Xmax95
的值。
var Xmas95 = new Date("December 25, 1995 23:15:00"); var day = Xmas95.getDate(); alert(day); // 25
规范版本 | 规范状态 | 注解 |
---|---|---|
ECMAScript 1st Edition. Implemented in JavaScript 1.1 | Standard | Initial definition. |
{{SpecName('ES5.1', '#sec-15.9.5.14', 'Date.prototype.getDate')}} | {{Spec2('ES5.1')}} | |
{{SpecName('ES6', '#sec-date.prototype.getdate', 'Date.prototype.getDate')}} | {{Spec2('ES6')}} |
|
{{Compat("javascript.builtins.Date.getDate")}}