Use details and differences between php time and date, and use details of date
Use difference between php time and date
1. time () function
The time () function in PHP uses the echo output to display a very long integer, which contains the date and time, which is a calculated value. To obtain a date format like Y-m-d H: I: s, you can use the date method:
Date ('Y-m-d H: I: s', time ());
Echo output it to get: 10:20:11
2. Date Format and string
We can build a date string, for example, 10:20:11. You can use the strtotime () function to convert the string into a value in time format. For example:
$ Time1 = strtotime ('2017-1-5 10:20:11 ');
Returns a long integer from the echo output.
Therefore, it can be understood as follows:
- The date is saved as a long integer in php. It can be converted to the date type through the date function, and the date type can directly output strings.
- You can use the strtotime () function to convert a date string to the time format (a long integer ).
- Date Format. You can use int to forcibly convert the data type and convert the data to an integer.
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!