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)
RozamundaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jSherzCommented:
<?php

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

?>

Open in new window

0
stu215Systems AnalystCommented:
Are you searching a database? array? textfile?

What is your dateformat?
0
RozamundaAuthor Commented:
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 ?
0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

jSherzCommented:
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

0
RozamundaAuthor Commented:
i found the solution myself:


  echo       date("y",strtotime('now - 5 years'));


jSherz - it would not work if the date was 2003
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stu215Systems AnalystCommented:
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
0
RozamundaAuthor Commented:
the provided solutions did not answer my question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.