For beginners, in hp, the date () mysql field is a 2012-02-2309: 24: 40 value stored in the datetime type. why is the date (Y-m-d, date field) used) what we get is how we can get ------ solution ---------------------- selectdate_format (date field, & quot; % Y-% m-% date () in hp ()
The mysql field is the value stored in the datetime type 09:24:40
Why is the date ('Y-m-D', date field) returned 1970-011?
How can I get it?
------ Solution --------------------
Select date_format (date field, "% Y-% m-% d") from table name
------ Solution --------------------
Use mysql functions. The date field in php is an integer timestamp.
------ Solution --------------------
The passed parameter should be int $ timestamp.
Echo date ('Y-m-D', strtotime ('now '));
Or directly
Echo date ('Y-m-D ');
If you want to get the time in mysql, you can convert it into a timestamp before conversion.
Date ('Y-m-D', strtotime (date field ));