$ Days = date ("y-m-d ");// Method 1 positive verification date The code is as follows:Copy code $ Reg = "/d {4}-d {2}-d {2 }/";Preg_match ($ reg, $ days, $ arr );Print_r ($ arr ); // Method 2 use cehckdate for verification The code is as
$ Date1 = "2007-10-25 ";$ Date2 = time ();Echo "$ date1 compare to $ date2 ";// 2007-10-25 compare to 1189772448$ Date1 = "2007-10-25 ";$ Date2 = date ("y-m-d", time ());Echo "$ date1 compare to $ date2 ";/*You don't know how big the difference
On the top page of the page, add
Date_default_timezone_set (PRC); /* Transfer time to Beijing time, php5 default to Greenwich Mean Time */
Date ()
A: "AM" or "PM"
A: "AM" or "PM"
D: A few days, two digits, if insufficient 0; from "01" to "31"
PHP Common functions at datetime time
?
"; The current timestamp echo time ()."; Echo Date (" Y-m-d h:i:s ").""; Gets the current time of the system echo date ("Y years M D Day H hour I min s second")."Echo Strtotime (" 2010 ").""; Conversion
One.(1) How many days to add or subtract the specified date(2) cycle the date between two specified datesCases:$start _time = ' 2017-07-01 ';$end _time = ' 2017-07-10 ';Get time difference$diff = Strtotime ($end _time)-strtotime ($start _time);$num =
Date () function
This function is more familiar.
The code is as follows
Copy Code
Echo ("Result with date (): ");Echo (Date ("L"). "");Echo (Date ("L DS of F Y h:i:s A"). "");Echo ("Oct 3,1975 is on a". Date ("L",
Of course, the date function of PHP is not possible to directly output the date of the Chinese, but you can use the following method to write a function.
The code is as follows
Copy Code
function today ()
There are times when you write PHP file upload programs that have this warning:
Upload: Screen Capture 2014-09-28_160214.pngType:image/pngsize:66.84765625 KbTemp file:d:\users\aven\appdata\local\temp\php742f.tmpWarning:move_uploaded_file ()
$time = ' 2010-1-11 ';Define a day I turn it into the 2010-01-1$splitDate = Explode ("-", $time);Split to "-" separate$stime = Mktime (0,0,0, $splitDate [1], $splitDate [2], $splitDate [0]);And then use Mktime to convert it into a time load.if
namebirthdayemailThis function is primarily used to check whether the submitted form data is wrong (validate)The actual application of user input data testing (validate) and filtering (filter) are involved in the program security, very important,
Here the date action function has an increase in time, calculated the date given is the day of the week, check the date is valid date time comparison function, return two date difference a few seconds, a few minutes, a few hours or a few days
Header (' content-type:text/html;charset=utf-8; ');#总结php操作时间的函数#1. Cal_days_in_month (calendar,month,year): function returns the number of days in one months for a specified year and calendar#calendar: The calendar to be used, month: Specified
$t=timeechodate("Y-m-d h:i:s",$tA-"AM" or "PM"A-"AM" or "PM"D-A few days, two digits, if less than two is the front 0; such as: "01" to "31"D-Days of the week, three English letters; such as: "Fri"F-month, full name in English; such as: "January"H-12
1, year-month-day
echo Date (' y-m-j ');
2007-02-6
echo Date (' y-n-j ');
07-2-6
Capital Y represents a four-digit year, while lowercase y represents a two-digit number for the year;
Lowercase m represents the number of months (with leading),
1.UNIX time StampPHPD processing of data, especially when the time type data in the database is formatted, it is necessary to convert the time type data into the UNIX timestamp processing. Data for time types in different database systems
cannot be
Phenomenon:
The phpmyadmin3.5 version (release-date-3.5.0, a configuration-optimized version of Phpmyadmin_3.5_path8.net) has been used, and this version is relatively concise and the newer PMA is a bit bloated. However, the use of php5.5, and php7.
Checkdate:
Verify the correctness of the date.
Date:
Format the time of the server.
Strftime:
The time of the server is formatted locally.
GETDATE:
Get time and date information.
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.