The year function is related to the problem, the online score

Source: Internet
Author: User
Tags echo date
Year function problem, online to divide

such as the number of years $year=, such as 5
$staff _join= began on the day of 2008-05-02
I am now going to add years to the beginning of the year, such as 2008-05-02+5=2013-05-02 with what expression Ah,
To be able to run the code, thank you

Little brother This ($Begin = (Date ("Y", $staff _join) + $year) error, output 1970)

------Solution--------------------
PHP Code
  
------Solution--------------------
This assignment is wrong.
$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
!--? PHP $value = 5; $year = Date (' Y '); $year + = $value  echo $year. Date ('-m-d '); 
------Solution--------------------
$year = 5;
$staff _join = ' 2008-05-02 ';

$Begin = Date ("y-m-d", Strtotime ("+ $year Year $staff _join));

------Solution--------------------
to the upstairs boss.
!--? php
$year = 5;
$staff _join = ' 2008-05-02 ';

$Begin = Date ("y-m-d", Strtotime ("+ $year year $staff _join"));
Echo $Begin;
?
------Solution--------------------
!--? php
$year = 5;
$staff _join = ' 2008-05-02 ';

$Begin = Date ("y-m-d", Strtotime ("+ $year year, $staff _join"));
Echo $Begin;
?
------Solution--------------------
appears to have been resolved
------solution--------------------
Strtotime
----- -Solution--------------------
Man, look into 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.