+3 Day:
echo date (' y-m-d h:i:s ', Strtotime (' +3 Day '));
+3 days:
echo Date (' y-m-d h:i:s ', Strtotime (' +3 days '));
The results of the output are the same.
The following are similar usages
Strtotime (' +1 Day ');
Strtotime (' +3 Day ');
Strtotime (' +1 days ');
Strtotime (' +3 days ');
Strtotime (' +1 weeks ');
Strtotime (' +3 Week ');
This problem occurs because PHP is not a strict programming language.
Some usages of strtotime function
1, Strtotime ("the") and Strtotime ("January")
The effects of these two usages are the same, which are returned today for the specified month, and are postponed to the next one months if the specified month is not today. In 2011-03-31, as calculated in February, the code:
echo Date ("Y-m-d h:i:s", Strtotime ("Feb", Strtotime ("2011-03-31"));
The program will output: 2011-03-03 00:00:00. On the surface, the result may not necessarily be what we want, but it is a solution, so what is the decision? The Strtotime function calculates the month only when the month is calculated, which is equivalent to setting the month directly to the value of the specified month, whereas Jan,january will have a corresponding internal value.
2, the single keyword
First is an auxiliary keyword that can be used in combination with the week, day can specify the value of the keyword combinations, such as a 2011-year of one Sunday:
echo Date ("Y-m-d h:i:s", Strtotime ("Second Sunday", Strtotime ("2011-01-01")), "<br/>";
In the PHP source code, for the combination of the week and day is separate, that is, a processing operation, in the final C implementation, the value of the day is specified as 1, that is, the D field in the time structure is specified as 1, the following code:
Switch (time->relative.first_last_day_of) {case
1:/* A/*
time->d = 1; Break
; Case
2:/* Last * *
time->d = 0;
time->m++; Break
;
}
3, Previous and Next keywords
Similar to first, the previous keyword can be used in combination with the week and day, representing the one weeks or days before the specified time. As shown in the following code:
echo Date ("Y-m-d h:i:s", Strtotime ("Previous Sunday", Strtotime ("2011-02-01")), "<br/>";
program output: 2011-01-30 00:00:00
The procedure is to ask for a Sunday before 2011-02-01.
The next keyword, in contrast to previous, represents the next one weeks or the following day.
4, last keyword
The last keyword can be either previous or final. If you ask for the date of the last Sunday:
echo Date ("Y-m-d h:i:s", Strtotime ("Last Sunday", Strtotime ("2011-02-05")), "<br/>";
program output: 2011-01-30 00:00:00
When the program is last, the scenario is the last day of the month on which the specified date is, equivalent to the result of date ("T"). For the last day of February 2000:
echo Date ("Y-m-d h:i:s", Strtotime ("Last Day", Strtotime ("2000-02-01")), "<br/>";
The previous, last, and this keywords belong to the same group in the re file.
5, Back and front keywords
These two keywords are the forward and backward operations of the hour of the day, and the calling format is as follows:
echo Date ("Y-m-d h:i:s", Strtotime ("Back of", Strtotime ("2011-02-01")), "<br/>";
echo Date ("Y-m-d h:i:s", Strtotime ("front of", Strtotime ("2011-02-01")), "<br/>";
The back represents the position of the one hour after the specified hour value is set to 15 points. If it is 24 o ' 0:15, Count to the next day.
Front represents the position of 45 points in the first one hours of the specified hour value for the time setting. If it's 0, it's 23:45 the day before.
The above code output: 2011-02-02-00:15:00 2011-02-01 23:45:00. Where back of and front of the array must be greater than or equal to 0 and less than or equal to 24.