phpはstrtotimeが便利なので簡単に作りたい
これくらいのものはfunction.phpに書かずにさらっと済ませたいので。
パラメータ末尾にdates=~~で先頭日と末日を指定してやるだけでいけそう。
<?php
$_func_getgcal_date = function($str_ymd) {
$tmp01d = date("Ym01",strtotime($str_ymd));
return $tmp01d."/".date("Ymd",strtotime('last day of '.$tmp01d));
};
$ymd_now = date("Ym01",strtotime($date("Ymd")));
$ymd_next = date("Ym01",strtotime($ymd_now." +1 month"));
$ymd_prev = date("Ym01",strtotime($ymd_now." -1 month"));
?>
<div class="_col">
<iframe src="https://calendar.google.com/calendar/embed?~~~~~~~&ctz=Asia/Tokyo&dates=<?php echo $_func_getgcal_date($ymd_now); ?>"></iframe>
</div>
<div class="_col">
<iframe src="https://calendar.google.com/calendar/embed?~~~~~~~&ctz=Asia/Tokyo&dates=<?php echo $_func_getgcal_date($ymd_next); ?>"></iframe>
</div>
<div class="_col">
<iframe src="https://calendar.google.com/calendar/embed?~~~~~~~&ctz=Asia/Tokyo&dates=<?php echo $_func_getgcal_date($ymd_prev); ?>"></iframe>
</div>
※注意
あくまで簡易的なものなので、ずれが発生する日付があります。
8月31日9月30日と大の月小の月が続くときの31日等々。
→1日をとって基準とすることで修正済み。
対策していくと関数が膨らみますので、ベースの簡易例としてお受け取りください。