取得今日,格式yyyy/MM/dd
。
function getTodayDate() {
var fullDate = new Date();
var yyyy = fullDate.getFullYear();
var MM = (fullDate.getMonth() + 1) >= 10 ? (fullDate.getMonth() + 1) : ("0" + (fullDate.getMonth() + 1));
var dd = fullDate.getDate() < 10 ? ("0"+fullDate.getDate()) : fullDate.getDate();
var today = yyyy + "/" + MM + "/" + dd;
return today;
}
取得明日,格式yyyy/MM/dd
。
function getTomorrowDate() {
var fullDate = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
var yyyy = fullDate.getFullYear();
var MM = (fullDate.getMonth() + 1) >= 10 ? (fullDate.getMonth()+1) : ("0" + (fullDate.getMonth() + 1));
var dd = fullDate.getDate() < 10 ? ("0" + fullDate.getDate()) : fullDate.getDate();
var today = yyyy + "/" + MM + "/" + dd;
return tomorrow;
}
沒有留言:
張貼留言