테스트 사이트 - 개발 중인 베타 버전입니다

남은날짜 구하기

트루모맨쇼 8개월 전 조회 1,440

$time = time();
$today = date("Y-m-d",strtotime("now", $time));
$month = date("Y-m-d",strtotime("+1 month", $time);
$max = $today - $month;
?>
        <input type="text" name="today" id="today" value="<?php echo $today ?>">
        <input type="text" name="month" id="month" value="<?php echo $month  ?>">
        <input type="text" name="max" id="max" value="<?php echo $max  ?>">

 

코드는 위와 같으며
오늘날짜와 한달뒤 날짜를 구해서 뺀값을 구하고 싶습니다

오늘날짜와 한달뒤 날짜는 정상적으로 구해지는데 

 

$max = $today - $month; 

 

이부분에서 어떻게 뺀값을 구해야할지 감이 안잡히네요 도움좀 부탁드립니다

 

 

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

P
8개월 전

strtotime의 결과값이 타임스탬프 값이니 date함수를 사용하시기 전에 차를 먼저 구하시면 됩니다.

strtotime("+1 month") - time();

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

8개월 전

</p>

<p><?php

$time = time();

$today = date("Y-m-d",strtotime("now", $time));

$month = date("Y-m-d",strtotime("+1 month", $time));

//$max = $today - $month;

$max_obj = date_diff(date_create($today), date_create($month));

$max = $max_obj->days;

?>

        <input type="text" name="today" id="today" value="<?php echo $today ?>">

        <input type="text" name="month" id="month" value="<?php echo $month  ?>">

        <input type="text" name="max" id="max" value="<?php echo $max  ?>"></p>

<p>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인