Skip to content

Instantly share code, notes, and snippets.

@ytkhs
Created March 6, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytkhs/c8eab3ffbad6636b5a19f38e0bb4eee4 to your computer and use it in GitHub Desktop.
Save ytkhs/c8eab3ffbad6636b5a19f38e0bb4eee4 to your computer and use it in GitHub Desktop.
phpでプレミアムフライデーかどうか判定する ref: http://qiita.com/qube81/items/9d17ddc4aa8ffb276bc9
<?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