新しいフォルダー

気になったことや勉強したことについて書いていきます

php その日の0時と23時59分59秒を取得

$s = date("Y-m-d 00:00:00", strtotime($s_date)));
$e = date("Y-m-d 23:59:59", strtotime($e_date)));

 

日付Aから日付Bの間に存在する日にちの0時と23時59分59秒を取得

 

$s = strtotime(date("Y-m-d 00:00:00", strtotime($s_date)));
$e = strtotime(date("Y-m-d 23:59:59", strtotime($e_date)));
$sec = 60 * 60 * 24;
$day_list = array();
for($i= $s ; $i <= $e; $i+=$sec){
$day_list[] = array('s_date' => date("Y-m-d 00:00:00", $i), 'e_date' => date("Y-m-d 23:59:59", $i));
}