function GetDate(format) {
/**
* format=1表示獲取年月日
* format=0表示獲取年月日時分秒
* **/
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth()+1;
var date = now.getDate();
var day = now.getDay();//得到周幾
var hour = now.getHours();//得到小時
var minu = now.getMinutes();//得到分鍾
var sec = now.getSeconds();//得到秒
if (format==1){
_time = year+"-"+month+"-"+date
}
else if (format==2){
_time = year+"-"+month+"-"+date+" "+hour+":"+minu+":"+sec
}
return _time
}
alert("當前日期為: " + GetDate(0));