PHP has the time function and date function. The difference between the two functions is obvious. However, it should be noted that time and date are two full time formats, of course, there is also a string format. This article focuses on the differences between these users. 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!
For more details and differences between the use of php time and date, refer to the PHP Chinese site!