Link to home
Start Free TrialLog in
Avatar of Rozamunda
Rozamunda

asked on

year 5 years ago

How to find a year which was 5 years ago  in PHP.

Like now we have 2011. I would like to have my starting year as "06" (with leading zeros)
Avatar of Member_2_5212910
Member_2_5212910
Flag of United Kingdom of Great Britain and Northern Ireland image

<?php

echo(date("Y") - 5);

?>

Open in new window

Avatar of stu215
Are you searching a database? array? textfile?

What is your dateformat?
Avatar of Rozamunda
Rozamunda

ASKER

jsherz:    it shows 69 ( ???)


stu215: i want to get "06" for the current year, next year i would like to get "07" .


What do you mean date format ? in php.ini ?
stu215: That's odd - on my installation it shows 2006.

Try this:
<?php

        $current_year = (int)date("Y");
        $current_year = $current_year - 5;
        echo($current_year);
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rozamunda
Rozamunda

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Using date() :

Y  = A full numeric representation of a year, 4 digits Examples: 1999 or 2003
y  = A two digit representation of a year Examples: 99 or 03
the provided solutions did not answer my question