function getServerDate (startDate) {
var xhr =null
if(window.XMLHttpRequest) {
xhr =new window.XMLHttpRequest()
}else{// ie
xhr =new ActiveObject('Microsoft')
}
xhr.open('GET','/',false) // false不可变
xhr.send(null)
vardate = xhr.getResponseHeader('Date') // open,send,和getResponseHeader必须按序编写
//转化服务器时间格式
var dates =newDate(date);
var seperator1 ="/";
var seperator2 =":";
var month = dates.getMonth() +1;
var strDate = dates.getDate();
if(month >=1&& month <=9) {
month ="0"+ month;
}
if(strDate >=0&& strDate <=9) {
strDate ="0"+ strDate;
}
var serverDate = dates.getFullYear() + seperator1 + month + seperator1 + strDate +" "+ dates.getHours() + seperator2 + dates.getMinutes() + seperator2 + dates.getSeconds();
return serverDate // yyyy/mm/dd hh:mm:ss
// GetDateDiff(startDate, serverDate)
}
//计算两个日期之间的天数
function GetDateDiff (startDate,endDate) {
varstartTime =newDate(startDate).getTime()
varendTime =newDate(endDate).getTime()
var dates = Math.abs((startTime - endTime)) / (1000*60*60*24)
return dates
}