您的位置:首页 > Web前端 > JavaScript

一个被我忽视的Javascript问题

2005-09-21 22:48 302 查看
前几日使用到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.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: