获取日期
1、date()
——返回当日的日期和时间。
2、getdate()
——从 date 对象返回一个月中的某一天 (1 ~ 31)。
3、getday()
——从 date 对象返回一周中的某一天 (0 ~ 6)。
4、getmonth()
——从 date 对象返回月份 (0 ~ 11)。
5、getfullyear()
——从 date 对象以四位数字返回年份。
6、getyear()
——请使用 getfullyear() 方法代替。
7、gethours()
——返回 date 对象的小时 (0 ~ 23)。
8、getminutes()
——返回 date 对象的分钟 (0 ~ 59)。
9、getseconds()
——返回 date 对象的秒数 (0 ~ 59)。
10、getmilliseconds()
——返回 date 对象的毫秒(0 ~ 999)
11、gettime()
——返回 1970 年 1 月 1 日至今的毫秒数。
设置日期
1、setdate()
——设置 date 对象中月的某一天 (1 ~ 31)。
2、setmonth()
——设置 date 对象中月份 (0 ~ 11)。
3、setfullyear()
——设置 date 对象中的年份(四位数字)。
4、sethours()
——设置 date 对象中的小时 (0 ~ 23)。
5、setminutes()
——设置 date 对象中的分钟 (0 ~ 59)。
6、setseconds()
——设置 date 对象中的秒钟 (0 ~ 59)。
7、setmilliseconds()
——设置 date 对象中的毫秒 (0 ~ 999)。
8、settime()
——以毫秒设置 date 对象。
--------------------------------------------------
js date 对象用于处理日期和时间。
创建 date 对象的语法:
var mydate=new date()
date 对象会自动把当前日期和时间保存为其初始值。
参数形式有以下5种:
new date(month dd,yyyy hh:mm:ss);
new date(month dd,yyyy);
new date(yyyy,mth,dd,hh,mm,ss);
new date(yyyy,mth,dd);
new date(ms);
注意最后一种形式,参数表示的是需要创建的时间和gmt时间1970年1月1日之间相差的毫秒数。各种函数的含义如下:
month:用英文表示月份名称,从january到december
mth:用整数表示月份,从0-11(1月到12月)
dd:表示一个月中的第几天,从1到31
yyyy:四位数表示的年份
hh:小时数,从0(午夜)到23(晚11点)
mm:分钟数,从0到59的整数
ss:秒数,从0到59的整数
ms:毫秒数,为大于等于0的整数
如:
new date(january 12,2006 22:19:35);
new date(january 12,2006);
new date(2006,0,12,22,19,35);
new date(2006,0,12);
new date(1137075575000);
date() 返回当日的日期和时间。
getdate() 从 date 对象返回一个月中的某一天 (1 ~ 31)。
getday() 从 date 对象返回一周中的某一天 (0 ~ 6)。
getmonth() 从 date 对象返回月份 (0 ~ 11)。
getfullyear() 从 date 对象以四位数字返回年份。
getyear() 请使用 getfullyear() 方法代替。
gethours() 返回 date 对象的小时 (0 ~ 23)。
getminutes() 返回 date 对象的分钟 (0 ~ 59)。
getseconds() 返回 date 对象的秒数 (0 ~ 59)。
getmilliseconds() 返回 date 对象的毫秒(0 ~ 999)。
gettime() 返回 1970 年 1 月 1 日至今的毫秒数。
gettimezoneoffset() 返回本地时间与格林威治标准时间 (gmt) 的分钟差。
getutcdate() 根据世界时从 date 对象返回月中的一天 (1 ~ 31)。
getutcday() 根据世界时从 date 对象返回周中的一天 (0 ~ 6)。
getutcmonth() 根据世界时从 date 对象返回月份 (0 ~ 11)。
getutcfullyear() 根据世界时从 date 对象返回四位数的年份。
getutchours() 根据世界时返回 date 对象的小时 (0 ~ 23)。
getutcminutes() 根据世界时返回 date 对象的分钟 (0 ~ 59)。
getutcseconds() 根据世界时返回 date 对象的秒钟 (0 ~ 59)。
getutcmilliseconds() 根据世界时返回 date 对象的毫秒(0 ~ 999)。
parse() 返回1970年1月1日午夜到指定日期(字符串)的毫秒数。
setdate() 设置 date 对象中月的某一天 (1 ~ 31)。
setmonth() 设置 date 对象中月份 (0 ~ 11)。
setfullyear() 设置 date 对象中的年份(四位数字)。
setyear() 请使用 setfullyear() 方法代替。
sethours() 设置 date 对象中的小时 (0 ~ 23)。
setminutes() 设置 date 对象中的分钟 (0 ~ 59)。
setseconds() 设置 date 对象中的秒钟 (0 ~ 59)。
setmilliseconds() 设置 date 对象中的毫秒 (0 ~ 999)。
settime() 以毫秒设置 date 对象。
setutcdate() 根据世界时设置 date 对象中月份的一天 (1 ~ 31)。
setutcmonth() 根据世界时设置 date 对象中的月份 (0 ~ 11)。
setutcfullyear() 根据世界时设置 date 对象中的年份(四位数字)。
setutchours() 根据世界时设置 date 对象中的小时 (0 ~ 23)。
setutcminutes() 根据世界时设置 date 对象中的分钟 (0 ~ 59)。
setutcseconds() 根据世界时设置 date 对象中的秒钟 (0 ~ 59)。
setutcmilliseconds() 根据世界时设置 date 对象中的毫秒 (0 ~ 999)。
tosource() 返回该对象的源代码。
tostring() 把 date 对象转换为字符串。
totimestring() 把 date 对象的时间部分转换为字符串。
todatestring() 把 date 对象的日期部分转换为字符串。
togmtstring() 请使用 toutcstring() 方法代替。
toutcstring() 根据世界时,把 date 对象转换为字符串。
tolocalestring() 根据本地时间格式,把 date 对象转换为字符串。
tolocaletimestring() 根据本地时间格式,把 date 对象的时间部分转换为字符串。
tolocaledatestring() 根据本地时间格式,把 date 对象的日期部分转换为字符串。
utc() 根据世界时返回 1997 年 1 月 1 日 到指定日期的毫秒数。
valueof() 返回 date 对象的原始值。
//var objdate=new date([arguments list]);