--- title: Date.prototype.getDate() slug: Web/JavaScript/Reference/Global_Objects/Date/getDate translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate --- <p>{{JSRef("Global_Objects", "Date")}}</p> <p>根据本地时间,返回一个指定的日期对象为一个月中的哪一日(从1--31)。</p> <div>{{EmbedInteractiveExample("pages/js/date-getdate.html")}}</div> <h2 id="Syntax">语法</h2> <pre class="brush: js">dateObj.getDate()</pre> <h2 id="Parameters">参数</h2> <p>无</p> <h2 id="Description">描述</h2> <p><code>getDate() </code>返回一个1 到 31的整数值。</p> <h2 id="Examples">例子</h2> <h3 id="Example:_Using_getDate">例子: 使用getDate()<code>方法</code></h3> <p>下面第二条语句将值25赋给 day 变量,该值基于日期对象 <code>Xmax95</code>的值。</p> <pre class="brush:js">var Xmas95 = new Date("December 25, 1995 23:15:00"); var day = Xmas95.getDate(); alert(day); // 25</pre> <h2 id="规范">规范</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">规范版本</th> <th scope="col">规范状态</th> <th scope="col">注解</th> </tr> <tr> <td>ECMAScript 1st Edition. Implemented in JavaScript 1.1</td> <td>Standard</td> <td>Initial definition.</td> </tr> <tr> <td>{{SpecName('ES5.1', '#sec-15.9.5.14', 'Date.prototype.getDate')}}</td> <td>{{Spec2('ES5.1')}}</td> <td> </td> </tr> <tr> <td>{{SpecName('ES6', '#sec-date.prototype.getdate', 'Date.prototype.getDate')}}</td> <td>{{Spec2('ES6')}}</td> <td> <p> </p> </td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.Date.getDate")}}</p> <h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> <li>{{jsxref("Date.prototype.getUTCDay()")}}</li> <li>{{jsxref("Date.prototype.setDate()")}}</li> </ul>