How to convert date types in php
This article introduces the relevant knowledge of "how to convert date types in php". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Use the date () function to convert the UNIX timestamp to a date.
2. Use the strtotime () function to convert the date into a UNIX timestamp.
Date format conversion can be done in PHP, but one disadvantage is that it takes up the parsing time of the PHP parser, so it is relatively slow. However, this approach also has the advantage that the data obtained by the query in the database can be converted, and the scope of conversion is not limited.
Example
$y=date ("Y", time ()); / year $m=date ("m", time ()); / / month $d=date ("d", time ()); / / Day echo $y. "; echo $m."; echo $d. ""; $eight_clock = mktime (8,0,0, $m, $d, $y); / / 8 o'clock echo date ("Y-m-d H:i:s", $eight_clock) every day. " $day_time = mktime (0,0,0, $m, 1, $y); / / echo date ("Y-m-d H:i:s", $day_time) on the 1st of each month. ";" how to convert date types in php "ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!