LoginSignup
0
0

More than 5 years have passed since last update.

日付を1日ずつ増やしながら表示する

Posted at

<?php
// 抽出対象期間
$startYmd='2016-02-01';
$endYmd='2017-02-01';

// timestampに変換
$startTimestamp = strtotime($startYmd);
$endTimestamp = strtotime($endYmd);

// ループの中で増えていくtimestamp
$steppingTimestamp = $startTimestamp;
$sqlUnions = '';
while($steppingTimestamp <= $endTimestamp)
{
    echo date('Ymd', $steppingTimestamp);
    // 最終ループ調整
    if ($steppingTimestamp != $endTimestamp) {
        echo ',';
    }

    // 一日増やす
    $steppingTimestamp = strtotime("+1 days", $steppingTimestamp);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0