Created
March 6, 2017 11:29
-
-
Save ytkhs/c8eab3ffbad6636b5a19f38e0bb4eee4 to your computer and use it in GitHub Desktop.
phpでプレミアムフライデーかどうか判定する ref: http://qiita.com/qube81/items/9d17ddc4aa8ffb276bc9
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 | |
function is_premium_friday(Datetime $date) { | |
return $date->diff(new DateTime(sprintf('last Fri of %s', $date->format('Y-m'))))->format('%d') == 0; | |
} | |
var_dump(is_premium_friday(new Datetime('2017-02-23'))); // false | |
var_dump(is_premium_friday(new Datetime('2017-02-24'))); // true | |
var_dump(is_premium_friday(new Datetime('2017-02-25'))); // false | |
var_dump(is_premium_friday(new Datetime('2017-03-31'))); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment