특정일 또는 기념일을 카운트다운 할 때 이용할 수 있습니다.
var before=" 크리스마스 ";
var current=" 즐거운 크리스마스! ";
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function countdown(yr,m,d){
var today = new Date();
var year = today.getYear();
if (year < 1000) year += 1900;
var month = today.getMonth();
var day = today.getDate();
var todaystring = montharray[month] + " " + day + ", " + year;
var futurestring=montharray[m-1] + " " + d + ", " + yr;
var difference = (Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1);
if (difference==0){
document.write(current);
}else if (difference>0){
document.write(before + "가 "+difference+" 일 남았네요!");
}
}
countdown(2015,12,25(Yr,m,d));
등록된 댓글이 없습니다.