PHP: How to Get Previous Year, Current Year, and Next Year

Because I can forget things easily if I don’t use it often and I’m sure this will be used again in the future, I should make a note about it.

Getting certain year using this method is very useful when we make a dynamic application, like in registration form in which we want to limit the age of the registrants, we can use this.

  • To get current year: date(‘Y’);
  • To get previous year: date(‘Y’, strtotime(‘-1 year’));
  • To get next year: date(‘Y’, strtotime(+1 year’));

If you want to get last two year or the next two year, just change -1 to -2 or +1 to +2

Short Break…

I tried to control myself to stay away from work. I kept reminding myself about it each time I’d do something to work.

The past several weeks were very tiring for me – staying up til midnight to work, thinking about unfinished jobs, worrying about job’s deadlines, reviewing some performances, thinking about my goals, etc.

I know that I have a limit. My mind and body were getting too tired..

Having enough sleep, watching film (I use to watch gossip girl and 2 broke girls weekly, but since it’s season break so there’s nothing to watch. Okay, I have to admit that I already watched Harry Potter 1-4 lately and I hope to finish all soon), playing games, installing some apps at my phone, and trying to make a post mobile ;).

Ready to begin tomorrow with new and fresh spirit! :)