Year function related questions, online score-php Tutorial

Source: Internet
Author: User
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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.