当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JavaScript getUTCDay()方法

JavaScript
JS 介绍
JS 怎样使用
JS 在哪使用
JS 变量
JS If...Else
JS Switch
JS 操作符
JS Popup Boxes
JS 函数
JS For 循环
JS While 循环
JS Break 循环
JS For...In
JS 事件
JS Try...Catch
JS Throw
JS onerror
JS 特殊字符
JS Guidelines
JS 对象介绍

JavaScript getUTCDay()方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 272 ::
收藏到网摘: n/a

Definition and Usage
定义与用法

The getUTCDay() method returns a number that represents the day of the week according to the Universal Coordinated Time (UTC).
根据UTC,getUTCDay()方法返回代表星期的数字

Syntax
语法

dateObject.getUTCDay()


Tips and Notes
提示与注意点

Note: The value returned by getUTCDay() is a number between 0 and 6. Sunday is 0, Monday is 1 and so on.
注意:getUTCDay()所返回的值在0到6之间。星期天是0,星期一是1,依次类推

Note: This method is always used in conjunction with a Date object.
注意:这个方法得结合Date对象使用

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.
提示:UTC是由国际时间标准设定的。


Example
举例

In this example we get the current UTC day (as a number) of the week:
在这个举例中我们得到了当前的UTC星期:

<script type="text/javascript">
var d=new Date()
document.write(d.getUTCDay())
</script>

The output of the code above will be:
输出结果为:



Example 2
举例 2

Now we will create an array to get our example above to write a weekday, and not just a number:
现在我们建立一个数组来显示星期名称,而不是简单的数字:

<script type="text/javascript">
var d=new Date()
var weekday=new Array(7)
weekday[0]="Sunday"
weekday[1]="Monday"
weekday[2]="Tuesday"
weekday[3]="Wednesday"
weekday[4]="Thursday"
weekday[5]="Friday"
weekday[6]="Saturday"
document.write("Today it is " + weekday[d.getUTCDay()])
</script>

The output of the code above will be:
输出结果为:



Try-It-Yourself Demos
尝试与演示

getUTCDay()
Use getUTCDay() and an array to write a weekday, and not just a number.
使用getUTCDay()和数组来显示星期,而不仅仅是数字

评论 (0) All

登陆 | 还没注册?