The usage difference between PHP time and date dates
1. Time () function
The time () function in PHP, using the echo output, is a very long integer that contains the date and times and is a computed value. If you want to get a date format such as y-m-d h:i:s, you can use the date method:
Date (' y-m-d h:i:s ', Time ());
echo output It can be obtained: 2016-1-5 10:20:11
2, date format and string
We can build a string of date format, such as: 2015-1-1 10:20:11. You can use the Strtotime () function to convert this string to a value in time format. Such as:
$time 1 = strtotime (' 2016-1-5 10:20:11 ');
This value, echo output, gets a long integer.
So, you can understand this:
- The date is saved in PHP as a long shaping number. It can be converted to a date (estimate and date) type through the date function, and the date type can directly output the string.
- Date strings can be converted to time format (that is, long integers) using the Strtotime () function.
- Date format, you can force type conversions through int, and convert growth integers.
Thank you for reading, I hope to help you, thank you for your support for this site!