javascript中日期函数Date详解
来源:互联网 发布:在兴唐通信上班 知乎 编辑:程序博客网 时间:2024/06/09 14:23
对象: 日期
Date是javascript预定义主题. 该主题包括可获取或设置系统日期、时间、月、日、小时、分钟、秒等等。包括函数方法获取 UTC 格式的日期。 UTC 是国际标准时间,也称格林尼治标准时间(Greenwich Mean Time)。
在使用这些方法前可先声明一个主题。
创建新日期主题
示例代码:var exd = new Date();
调用"new Date()" 将创建一个日期主题。该主题可用于调用过程或函数。我们必须在变量中获取该主题。在上述示例代码中该主题存储于变量 exd 中。
以下将使用 exd 作为示例。
exd.getDate();23 9getDate() 方法返回您当前系统日期中的天数。 其范围为 1 到 31。getUTCDate()exd = new Date();
exd.getUTCDate();23 9getUTCDate() 方法返回 UTC 日期中的天数。 UTC 是国际标准时间。getMonth()exd = new Date();
exd.getMonth();3 3getMonth() 方法返回您系统日期中的月份。 其范围是从 1 到 12. 1 是1月, 12 是12月。getUTCMonth()exd = new Date();
exd. getUTCMonth();3 3getUTCMonth() 方法返回您系统日期中的 UTC 时间中的月份。getDay()exd = new Date();
exd.getDay();5 5getDay() 方法返回您系统日期为一周中的星期几。 其返回范围为从 1 到 7. 1 为星期日, 2 是星期一, 到 7 为星期六。getUTCDay()exd = new Date();
exd.getUTCDay();5 5getUTCDay() 方法返回您系统 UTC 日期是一周中的星期几。getHours()exd = new Date();
exd.getHours();14 20getHours() 方法返回您系统日期的小时。 该范围是 0 到 24.getUTCHours()exd = new Date();
exd.getUTCHours();6 12getUTCHours() 方法返回您系统 UTC 日期的小时。 [中国时间比国际标准时间(UTC)快 8 小时].getMinutes()exd = new Date();
exd.getMinutes();2 32getMinutes() 方法返回您系统日期的分钟。 其结果范围是 0 到 59。getUTCMinutes()exd = new Date();
exd. getUTCMinutes();2 32getUTCMinutes() 方法返回您系统 UTC 日期的分钟。getSeconds()exd = new Date();
exd.getSeconds();1 30getSeconds() 方法返回您系统日期的分钟。 其结果范围是 0 到 59。getUTCSeconds()exd = new Date();
exd. getUTCSeconds();1 30getUTCSeconds() 方法返回您系统 UTC 日期的秒钟。getMilliseconds()exd = new Date();
exd.getMilliseconds();562 872getMilliseconds() 方法返回您当前系统时钟的毫秒数。getTime()exd = new Date();
exd.getTime();-结果: 1272002521562 1270816350872
getTime() 方法返回自 1970 年 1 月 1 日起到当前系统时间的毫秒数。getYear()exd = new Date();
exd.getYear();2010 110getYear() 方法返回自 1900 开始的当前时间的年份。getFullYear()exd = new Date();
exd.getFullYear();2010 2010getFullYear() 方法返回当前系统日期中的完整年份。toGMTString()exd = new Date();
exd.toGMTString();Fri, 23 Apr 2010 06:02:01 UTC Fri, 09 Apr 2010 12:32:30 GMTtoGMTString() 方法返回格林尼治标准时间(GMT)格式的日期、时间。
事实上 JavaScript 保存的是自 1970 年 1 月 1 日午夜起至今的毫秒数。 该日期称为纪元日期(Epoch Date)。
- javascript中日期函数Date详解
- javascript中日期(Date)字符串转换为日期(Date)对象
- JavaScript中日期和时间函数Date的简单用例
- java中日期date
- JavaScript中日期时间函数的扩展
- Lua中日期和时间函数详解
- SQL Date Functions/ 数据库中日期时间函数
- js中日期的比较,使用date.parse函数
- php中日期时间函数date()用法总结
- java中日期Date格式化
- easyUI中日期问题date
- javascript中日期比较
- oracle中日期函数
- C++中日期函数
- 数据库中日期函数
- js中日期函数
- sqlserver中日期函数
- javaScript中日期的计算 UTC函数语法
- HTTP POST GET详解
- 字符串反转的N种方法(转)
- 等待
- 用Flash做点击页面图片切换效果的超级详细教程
- JUnit 4 简单使用
- javascript中日期函数Date详解
- 检测远程URL是否存在的三种方法
- xml的序列化和反序列化
- Zend Framework 1.10.1 快速入门之一:Zend Framework & MVC 介绍
- 何谓数据结构
- 编写开发库
- javascript对table行的一些相关控制
- BMP 的编码与解码
- 交换两数,不使用第三变量,且考虑溢出问题