Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Date.prototype.getDay()

概述

getDay() 方法根据本地时间,返回一个具体日期中一周的第几天,0 表示星期天。

语法

dateObj.getDay()

参数

返回值

getDay() 返回一个整数值: 0 代表星期日, 1 代表星期一,2 代表星期二, 依次类推。

例子

例子:使用getDay方法

下面第二条语句,基于日期对象 Xmas95 的值,把 1 赋值给 weekday。也就是说1995年12月25日是星期一。

var Xmas95 = new Date("December 25, 1995 23:15:00");
var weekday = Xmas95.getDay();

alert(weekday); // 1

规范

规范版本 规范状态 注解
ECMAScript 1st Edition. Implemented in JavaScript 1.0 Standard Initial definition.
ECMAScript 5.1 (ECMA-262)
Date.prototype.getDay
Standard  
ECMAScript 6 (ECMA-262)
Date.prototype.getDay
Release Candidate  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

 此页面的贡献者: teoli, AlexChao, ziyunfei
 最后编辑者: teoli,