php 날짜 비교
<?
/*
int mktime(시,분,초,월,일,년);
string date(string format, int timestamp);
array getdate(int timestamp);
*/
$start_time = mktime(0,0,1,6,26,2004); //timestamp값(현재 초단위의 유닉스 시간 반환)
$end_time = $start_time + 864000; //10일 후의 초단위의 유닉스 시간 구함
$now_time = mktime(); //현재의 timestamp값
$end_timeinfo = getdate($end_time); //종료일의 날짜정보 배열
$now_timeinfo = getdate($now_time); //현재의 날짜정보 배열
//echo $end_timeinfo["yday"]."일<br>"; //종료일이 1년 365일중 몇일째인가 출력
//echo $now_timeinfo["yday"]."일<br>"; //현재날짜가 1년 365일중 몇일째인가 출력
$excess = $now_timeinfo[yday] - $end_timeinfo[yday]; //초과된날짜 계산
$start_date = date('Y년 m월 d일',$start_time); //시작일의 출력 형식 지정
$end_date = date('Y년 m월 d일',$end_time); //종료일의 출력 형식 지정
echo("시작일 : {$start_date} ({$start_time}초)<p>");
echo("종료일 : {$end_date} ({$end_time}초)<p>");
if ($delay > 0)
echo("초과일 : {$excess}일");
else
echo("초과되지 않음");
?>
$newicon ="";
$crtdate=mktime(0,0,0,substr($faq['created'],5,2),substr($faq['created'],8,2),substr($faq['created'],0,4));
$nowdate=mktime(0,0,0,date("m"),date("d"),date("Y"));
if(($nowdate - $crtdate)/(24*60*60) < 5){
$newicon = " <img src='/img/boards/icons/01/icon_new.gif' alt='new' />";
}