Bestcomy.net blog

Coding for funny

导航

一个被我忽视的Javascript问题

Posted on 2005-09-21 22:48  bestcomy  阅读(3301)  评论(6编辑  收藏  举报
前几日使用到Javascript的Date初始化一个日期
var dt = new Date(2005,8,31)
结果发现dt.getDate()为1

仔细查了一下Javascript参考才发现,原来如此

Versions prior to JavaScript 1.3:

new Date()
new Date(milliseconds)
new Date(dateString)
new Date(yr_num, mo_num, day_num[, hr_num, min_num, sec_num])


Parameters



milliseconds

 

Integer value representing the number of milliseconds since 1 January 1970 00:00:00.  

dateString

 

String value representing a date. The string should be in a format recognized by the Date.parse method.  

yr_num, mo_num,
day_num

 

Integer values representing part of a date. As an integer value, the month is represented by 0 to 11 with 0=January and 11=December.  

hr_num, min_num,
sec_num, ms_num

 

Integer values representing part of a date.