반응형
https://blog.munilive.com/posts/In-strtotime-1-months-or-1-month-ago-is-not-30-days-old.html
strtotime에선 -1 months 또는 1 month ago는 30일 이전이 아니다.
PHP 5.x버전의 strtotime 함수에서 한달전의 계산에 오류가 있는 내용에 대한 설명과 그 해결 방법에 관한 글이다.
blog.munilive.com
샘플정보
<?
$date = "2013-03-30";
$time = strtotime($date);
$prev_month = strtotime("1 months ago", $time);
echo date("Y-m-d", $prev_month);
//결과값 : 2013-03-02
?>
----------------
결론 : first day of 를 이용하여 정확한 달을 만들어야한다
1달전
strtotime("first day of -1 months",$time)
반응형
'기타 > PHP' 카테고리의 다른 글
cURL error 60: SSL certificate (0) | 2022.11.25 |
---|---|
There is no active transaction (0) | 2022.10.26 |
'' // "" // 따옴표처리 (0) | 2020.03.31 |
fcm (0) | 2019.09.10 |
curl (0) | 2019.09.10 |