[php][日付け]指定日と日数を入力してその期間の日付け配列を取得する
1 2 3 4 5 6 7 8 9 |
//開始日から指定日数分のdate 配列の取得 private function get_date_list($begin, $count){ $i = 0; $arr_date=[]; while($i < $count){ $arr_date[] = date( "Y-m-d", strtotime("$begin +$i day ") ); $i++; } return $arr_date; |
こんな感じ。
関連記事
-
-
[php]期間指定で月一覧、日付一覧のデータ取得
123456789101112131415161718192021222324#日付けで取得(yyyy-mm-dd)function get_period_date (){$startDate = date('Y-m-d', strtotime('2018-01-06'));$endDate = date('Y-m-d', strtotime("2018-01-09"));$diff = (strtotime($endDate) - strtotime($startDate)) / ( 60 * 60 * 24);for($i = 0; $i <= $diff; $i++) {$period[] = date('Y-m-d', strtotime($startDate . '+' . $i . 'days'));}return $period;}#月(yyyy-mm)で取得function get_period_month(){$startDate = date('Y-m-d', strtotime('2017-01-06'));$endDate = date('Y-m-d', strtotime("2018-01-09"));$diff = (strtotime($endDate) - strtotime($startDate)) / ( 60 * 60 * 24 * 30);for($i = 0; $i <= $diff; $i++) {$period[] = date('Y-m', strtotime($startDate . '+' . $i . 'month'));}return $period;}
-
-
【PHP】【Slim】テンプレートの利用
テンプレートの利用 【参考】PHPマイク …
-
-
アンケートOSS lime surveyを軽く使ってみてのメモ
varsion 1.92 良い所 作成できるアンケートは多岐にわたり、細かい設定 …
-
-
CentOSをインストールしたときにいつも最初にやること(apache mysql phpのインストール)
SElinuxの無効化 iptableの無効化 apacheのインストール・自動 …
-
-
[ruby][php]Excel出力操作の方法
Excel出力が要件としてもとめられた、言語は問わない、WEBではなくバッチで。 …