Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
次のもっともっと交流ステーションの日付を表示するスニペット ref: http://qiita.com/TakamiChie/items/94742b098c2bb5ef4216
<?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');
}
?>
[[NextMottoMotto]]
もしくは、
[[NextMottoMotto?format=`Y年m月d日`]] など
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment