For beginners, in hp, the date () mysql field is a 2012-02-2309: 24: 40 value stored in the datetime type. why use date ('Y-m-D', date field) what we get is how we can get, selectdate_format (date field, & quot; % Y-beginner question in hp date ()
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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.