1.Date 对象用于处理日期和时间。创建 Date 对象的语法:var myDate=new Date()Date 对象会自动把当前日期和时间保存为其初始值。2.参数形式有以下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日之间相差的毫秒数。3.各种函数的含义如下:month:用英文表示月份名称,从January到Decembermth:用整数表示月份,从(1月)到11(12月)dd:表示一个月中的第几天,从1到31yyyy:四位数表示的年份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 日至今的毫秒数。
转载于:https://www.cnblogs.com/huanghuali/p/8431943.html