次のもっともっと交流ステーションの日付を表示するスニペット ref: http://qiita.com/TakamiChie/items/94742b098c2bb5ef4216
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 | |
/* | |
* NextMottoMotto | |
* Author:高見知英( http://onpu-tamago.net/ ) | |
* 次のもっともっと交流ステーションの日付を取得するスニペット | |
*/ | |
if(!isset($format)) { | |
$format="Y/m/d"; | |
} | |
$first = new DateTime(); | |
$date = clone $first; | |
$first->modify( 'first day of this month' ); | |
if($date > nextFirstFriday($first)){ | |
$date->modify( 'first day of next month' ); | |
$m = $date->format('m'); | |
$w = $date->format('w'); | |
if($m == '01' || ($m == '05' && $w < 4)){ | |
$date->modify( 'first day of next month' ); | |
} | |
} | |
$date = nextFirstFriday($date); | |
return $date->format($format); | |
function nextFirstFriday($date) | |
{ | |
$calc = clone $date; | |
return $calc->modify('1 Fri'); | |
} | |
?> |
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
[[NextMottoMotto]] | |
もしくは、 | |
[[NextMottoMotto?format=`Y年m月d日`]] など |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment