Currently when I want to get today's date irrespective of time, I have to do the following.
$Date = new DateTime('now');
$Date->setTime(0,0,0);
Is there a more eloquent way of doing this? Preferably a one-liner
Currently when I want to get today's date irrespective of time, I have to do the following.
$Date = new DateTime('now');
$Date->setTime(0,0,0);
Is there a more eloquent way of doing this? Preferably a one-liner
Assuming you are using PHP 5.4+
$Date = (new DateTime('now'))->setTime(0,0,0);
Or
$Date = new DateTime('midnight');