javascript获取时间

一、获取当前时间 new Date()方法---------得到结果是当前电脑时间如2011-11-6,10:07

二、获取有个固定的时间方法---------var endtime=new Date("2013/10/01,18:25:00");

三、时间转化成毫秒数----------endtime.getTime();

四、获取当前的年份-----------endtime.getYear();

                  -------------endtime.getFullyear();

    两者的区别在于getyear不兼容火狐浏览器,getFullyear兼容好

五、获取当前的月份---------endtime.getMonth();

六、获取当前的日------getDay

七、获取小时--------getHours

八、myDate.getMilliseconds(); //获取当前毫秒数(0-999) 九、myDate.toLocaleDateString(); //获取当前日期 十、var mytime=myDate.toLocaleTimeString(); //获取当前时间 十一、myDate.toLocaleString( ); //获取日期与时间

Date.prototype.isLeapYear 判断闰年
Date.prototype.Format 日期格式化
Date.prototype.DateAdd 日期计算
Date.prototype.DateDiff 比较日期差
Date.prototype.toString 日期转字符串
Date.prototype.toArray 日期分割为数组
Date.prototype.DatePart 取日期的部分信息
Date.prototype.MaxDayOfDate 取日期所在月的最大天数
Date.prototype.WeekNumOfYear 判断日期所在年的第几周
StringToDate 字符串转日期型
IsValidDate 验证日期有效性
CheckDateTime 完整日期时间检查
daysBetween 日期天数差

原文地址:https://www.cnblogs.com/dongbo19910728/p/3896436.html