javascript中日期函数Date详解
对象: 日期
Date是javascript预定义主题. 该主题包括可获取或设置系统日期、时间、月、日、小时、分钟、秒等等。包括函数方法获取 UTC 格式的日期。 UTC 是国际标准时间,也称格林尼治标准时间(Greenwich Mean Time)。
在使用这些方法前可先声明一个主题。
创建新日期主题
示例代码:var exd = new Date();
调用"new Date()" 将创建一个日期主题。该主题可用于调用过程或函数。我们必须在变量中获取该主题。在上述示例代码中该主题存储于变量 exd 中。
以下将使用 exd 作为示例。
方法
示例代码
结果
说明
getDate()
exd = new Date();
exd.getDate();
23 9
getDate() 方法返回您当前系统日期中的天数。 其范围为 1 到 31。
getUTCDate()
exd = new Date();
exd.getUTCDate();
23 9
getUTCDate() 方法返回 UTC 日期中的天数。 UTC 是国际标准时间。
getMonth()
exd = new Date();
exd.getMonth();
3 3
getMonth() 方法返回您系统日期中的月份。 其范围是从 1 到 12. 1 是1月, 12 是12月。
getUTCMonth()
exd = new Date();
exd. getUTCMonth();
3 3
getUTCMonth() 方法返回您系统日期中的 UTC 时间中的月份。
getDay()
exd = new Date();
exd.getDay();
5 5
getDay() 方法返回您系统日期为一周中的星期几。 其返回范围为从 1 到 7. 1 为星期日, 2 是星期一, 到 7 为星期六。
getUTCDay()
exd = new Date();
exd.getUTCDay();
5 5
getUTCDay() 方法返回您系统 UTC 日期是一周中的星期几。
getHours()
exd = new Date();
exd.getHours();
14 20
getHours() 方法返回您系统日期的小时。 该范围是 0 到 24.
getUTCHours()
exd = new Date();
exd.getUTCHours();
6 12
getUTCHours() 方法返回您系统 UTC 日期的小时。 [中国时间比国际标准时间(UTC)快 8 小时].
getMinutes()
exd = new Date();
exd.getMinutes();
2 32
getMinutes() 方法返回您系统日期的分钟。 其结果范围是 0 到 59。
getUTCMinutes()
exd = new Date();
exd. getUTCMinutes();
2 32
getUTCMinutes() 方法返回您系统 UTC 日期的分钟。
getSeconds()
exd = new Date();
exd.getSeconds();
1 30
getSeconds() 方法返回您系统日期的分钟。 其结果范围是 0 到 59。
getUTCSeconds()
exd = new Date();
exd. getUTCSeconds();
1 30
getUTCSeconds() 方法返回您系统 UTC 日期的秒钟。
getMilliseconds()
exd
相关文档:
按钮式:
<INPUT name="pclog" type="button" value="/GO" onClick="location.href='http://game.unimagic.cn'">
链接式:
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
直接跳转式:
<scrip ......
<script language="javascript">
function ShowTableRow(id)
{
var _Row = document.getElementById(id) <!-- 获取ID为TableRowID 的对象 -->
var _Img = document.getElementById("Img"+id)
&nb ......
jQuery, MooTools, Prototype 等优秀的
JavaScript 框架拥有各种强大的功能,包括绘制 Web 图表,使用这些框架以及相应插件,我们可以非常轻松地实现曲线图,圆饼图,柱状图等
Web 图表的绘制,而不必象以往那样通过复杂的 Flash 技术实现。本文介绍了9个优秀的基于 JavaScript 与 CSS& ......
css,javascript的预加载
为了提高网站的加载速度,有一个很重要的手段就是在用户浏览过程中的上游网站做一个文件的预加载。预加载文件一般有两种常用的方式:xhr和动态插入节点的方式。动态插入节点是最为简单也最为广泛的一种异步加载方式(例如yui的Get模块),然后使用动态插入节点方法加载的文件都会在加载后立即执行, ......
<asp:TextBox ID="txtPwdPrompt" runat="server"></asp:TextBox>
<asp:CustomValidator id="CVPwdPrompt" runat="server" ClientValidationFunction="CheckPwd" ControlToValidate="txtPwdPrompt" ErrorMessage="<span style='font:12px'>提示问题必须在2-50个字符内</span>" Display="None"&g ......