Year function problems, online score for the number of years that have passed $ year, for example, the year, month, and day starting from 5 $ staff_join, for example, I want to add the number of years to the start year, month, and day, for example, what expression is used for + 5 =? for code that can be run, thank you, brother. ($ Begin (date (& quot; Y & quot;, $ staff_join) + $ year) error. output 1 year function problem, online score
For example, $ year = the number of years that have passed, for example, 5
$ Staff_join = the start year, month, and day, for example, 2008-05-02
Now, I want to add the year, month, and day of the beginning, for example, + 5 = What is the expression used,
You can run the code. thank you.
In this case, the younger brother ($ Begin = (date ("Y", $ staff_join) + $ year) has an error and outputs 1970)
------ Solution --------------------
PHP code
------ Solution --------------------
The value assignment here is incorrect.
$ Staff_join = "20010-05-02 ";
Change to $ staff_join = "2010-05-02 ";
------ Solution --------------------
PHP code
"; Echo $ arrdate [0]; // 2013?>
------ Solution --------------------
$year = 5;
$staff_join='2008-05-02';
$join_date = mktime(0, 0, 0,
substr($staff_join, 5, 2), substr($staff_join, -2, 2), substr($staff_join, 0, 4));
echo date('Y-m-d', $join_date), "\n";
$join_date_5_years_later =
strtotime("+$year Year", $join_date );
echo date('Y-m-d', $join_date_5_years_later);
?>
------ Solution --------------------
PHP code
------ Solution --------------------
$ Year = 5;
$ Staff_join = '2017-2008 ';
$ Begin = date ("Y-m-d", strtotime ("+ $ year $ staff_join ));
------ Solution --------------------
Change it to the boss upstairs.
$ Year = 5;
$ Staff_join = '2017-2008 ';
$ Begin = date ("Y-m-d", strtotime ("+ $ year $ staff_join "));
Echo $ Begin;
?>
------ Solution --------------------
$ Year = 5;
$ Staff_join = '2017-2008 ';
$ Begin = date ("Y-m-d", strtotime ("+ $ year, $ staff_join "));
Echo $ Begin;
?>
------ Solution --------------------
It seems that the solution has been solved.
------ Solution --------------------
Strtotime
------ Solution --------------------
Dude, let's take a look at the strtotime function, which is described in detail in the manual.