Category Archives: Coding

Back to Coding!

Taun ini lumayan banyak ngoding sendiri (walaupun cm minor changes), but it’s fun and challenging! Asik juga ternyata cari-cari error dan ada kepuasan tersendiri pas berhasil menemukan di mana letak error tsb (norak ya, padahal kadang2 cm simple things). Masih ingat post sebelumnya? Sampai sekarang kalau coding ya paling seputar PHP & C#. For the latter, if I could choose, I want to use VB.NET. Sayangnya, gw gak bisa milih. 😛 Continue reading

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