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
This article mainly introduces the details of Laravel framework form verification. This article provides basic Laravel Form Verification examples, advanced usage methods, and verification methods. For more information, see
Basic verification example
PHP provides functions that can easily convert various forms of a date to a timestamp, which is mainly:
Strtotime (): Resolves the datetime description of any English text to a timestamp.
Mktime (): Gets the timestamp from the date.
Php's powerful time conversion function strtotime and php function strtotime. Php's powerful time conversion function strtotime. php's strtotime function uses strtotime to convert Time strings of various formats into timestamps to convert
Date Operation
To facilitate storage, comparison, and delivery, we often need to use the Strtotime () function to convert dates into Unix timestamps, and use the date () function to convert dates to the usual time format only when displayed to the
PHP time stamp and day conversion and calculation examples, Phpunix
Unix timestamps are a compact and concise way to save dates and times, a way to save the current date and time in most Unix systems, and a standard format for representing dates
1. unix_timestampConverts a time to a timestamp. Convert data of the date type to the timestamp formatThe timestamp of the current time is used by default.Mysql> select unix_timestamp ();+ ------ +| Unix_timestamp () |+ ------ +| 1, 1436775578 |+ ---
PHP provides functions to easily convert various forms of dates to timestamps, which are mainly: Strtotime (): Resolves the date-time description of any English text to a timestamp. Mktime (): Gets the timestamp from the date. strtotime ()
The
Date action
For ease of storage, comparison, and delivery, we typically use the Strtotime () function to convert a date to a UNIX timestamp and use the date () function to convert the date to the usual time format only when displayed to the user.
Php code for modifying the time format. For more information, see.
Php code for modifying the time format. For more information, see.
Modify time format:
Date ("Y-m-d", strtotime ($ list ['pubdate']);
Learning explanation: put the time
The general practice is to split the string into a function, and then obtain the required data, such as the number of days, month, and year, and then combine them to use the strtotime function for conversion.
If you encounter a log file date format
Php code for modifying the time format. For more information, see. Modify time format:
Date ("Y-m-d", strtotime ($ list ['pubdate']);
Learning explanation: put the time in strtotime as the timestamp and convert the format with date (). the
In PHP, compare the difference between the two time values and the date values. Here, we use the timestamp mktime (hour, minute, second, month, day, year, [is_dst]). its parameters can be left or right, any omitted parameter will be set as the local
Usually when we browse the site, often use the search function, in the search for information, careful users will find that at the bottom of the search results, generally have "search time for x seconds" of the word, which is the use of PHP
The
Php uses the date format to output the specified range of time requirements during log analysis today, because the logs are separated by days, I need to traverse the logs for 30 days, if the class is obtained & #20284; an array suffix such as 2013010
Php uses the date format to output the specified range of time requirements during log analysis today, because the logs are separated by days, I need to traverse the logs for 30 days, if the class is obtained & #20284; an array suffix such as 2013010
Today, I have nothing to do with a function, but I will use the strtotime function. I have converted the timestamp from the 2014-07-80: 0: 0 format. This example is very useful, here is an example. Implement function acquisition when the half time
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
In php, if you want to convert a date to a timestamp, you can directly use the strtotime function. If you want to convert a timestamp to a date, you can directly use the date () function, next I will introduce them to my friends.
The strtotime ()
In the process of doing the project, very frequently encountered the problem of time, like the comparison of time, a specific time to perform a certain action, but now only solve a part of the problem, first explain the question of time
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.