How does php determine what time it is?
Today, I would like to share with you the relevant knowledge about how to judge the current point of php. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Php method to determine the current time: 1, use the time () or strtotime () function to get the timestamp representing the current time; 2, use the "date (" H:i:s ", timestamp)" statement to format the timestamp, convert it to "hours: minutes: seconds" format and output.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php judges what time it is.
1. Get the timestamp that represents the current time
Method 1: use the time () function
The time () function returns the number of seconds in the current time since the Unix era (January 1 1970 00:00:00 GMT).
Syntax:
Time ()
Method 2:strtotime () function
The strtotime () function parses the date-time description of any string into an Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT).
Syntax:
Strtotime ("now")
2. Use the date () function to format the timestamp
Date ("H:i:s", timestamp)
Complete code:
These are all the contents of the article "how to judge what time it is now by php". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.