How to check if a Carbon date object is at the start of day?
In the meanwhile its even easier. Use the is....()
methods (see carbon comparison) like this:
$date = Carbon::now();
if($date->isStartOfDay()) { // check if hour is 00:00:00
// whatever
}
If you just want to check if it's the start of the day, then it's fairly easy to check with Carbon's startOfDay()
modifier and a comparison:
$date = Carbon::now(); // or whatever you're using to set it
$start = $date->copy()->startOfDay();
if($date->eq($start)) {
// do your formatting here
}