var myData = new Date() //Thu Mar 19 2020 21:26:45 GMT+0800 (中国标准时间)
myDate.toLocaleDateString() //"2020/3/19"
myDate.toLocaleTimeString() //"下午9:26:45"
myDate.toLocaleString( ) //"2020/3/19 下午9:26:45"
myDate.getFullYear() //2020
myDate.getMonth() //2 , 代表3月
myDate.getDate() //19
myDate.getDay() //4,周四,0代表星期天
myDate.getTime() //1584624405842,获取当前时间(从1970.1.1开始的毫秒数)
myDate.getHours() //21,获取当前小时数
myDate.getMinutes() //26
myDate.getSeconds() //45
myDate.getMilliseconds()//842,获取当前毫秒数
日期时间脚本库方法列表:
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 日期天数差