Created
March 30, 2012 01:20
-
-
Save brtriver/2245531 to your computer and use it in GitHub Desktop.
What result do you expect?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('Asia/Tokyo'); | |
if (date('n', strtotime('this month')) === date('n', strtotime('last month'))) { | |
echo "never call"; | |
} | |
// last month は前月の"同一日"を返そうとするので、 | |
// 2月30日 -> 3月1日 のように解釈されてしまう。 | |
// 前月の月を知りたい場合は 以下のようにfirst day of をつけないと先月が何月かを正確に取得できない! | |
$last_month = date('n', strtotime('first day of last month')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment