I need a DateTime object that sets hours, minutes and seconds to '00:00:00'
Why does the following still output '20:53:19' instead of '00:00:00'?
const DATETIME_TO_MYSQL_DATETIME = 'Y-m-d H:i:s';
const DATE_FORMAT = 'j.n.Y';
$this->today = DateTime::createFromFormat(self::DATE_FORMAT, (new DateTime())->format(self::DATE_FORMAT));
die($this->today->format(self::DATETIME_TO_MYSQL_DATETIME));
Output:
2013-12-02 20:53:19
Use:
const DATETIME_TO_MYSQL_DATETIME = 'Y-m-d 00:00:00';
if you want the hours/minutes/seconds to be 00:00:00
, regardless of time.
Just use:
$this->today = new DateTime('today');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With