Carbonを使ってみよう

require "vendor/autoload.php";

use Carbon\Carbon;

$dt = new Carbon();
echo $dt . "<br>";

$dt = Carbon::now();
echo $dt . "<br>";

$dt = new Carbon("2019-05-09");
echo $dt . "<br>";

$dt = Carbon::today();
echo $dt . "<br>";

$dt = Carbon::tomorrow();
echo $dt . "<br>";

$dt = Carbon::yesterday();
echo $dt . "<br>";

$dt = Carbon::parse("2019-05-07 10:30:30");
echo $dt . "<br>";

2019-05-07 20:54:17
2019-05-07 20:54:17
2019-05-09 00:00:00
2019-05-07 00:00:00
2019-05-08 00:00:00
2019-05-06 00:00:00
2019-05-07 10:30:30

なるほどー、確かに使いやすいかもね~