PHP - Show the date with hours, minutes and seconds set to zero
date, format, php
Solution
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.
Problem
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`