1.在页面加载后就自动执行下面的代码:
$(document).ready(function() {
// 放执行的内容
})
2. js 时间操作
var myDate = new Date();
myDate.getYear();
myDate.getFullYear();
myDate.getMonth();
myDate.getDate();
myDate.getDay();
myDate.getTime();
myDate.getHours();
myDate.getMinutes();
myDate.getSeconds();
myDate.getMilliseconds();
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 日期天数差
function format(temp){
if(temp<10){
return "0"+temp;
}else{
return temp;
}
}
var myDate = new Date();
var year=myDate.getFullYear();
var month=format(myDate.getMonth()+1);
var day=format(myDate.getDate());
var hour= format(myDate.getHours());
var min= format(myDate.getMinutes());
var ss= format(myDate.getSeconds());