PHP code to return year?

  • artcoder
  • Student
  • Student
  • User avatar
  • Posts: 89
  • Loc: United States

Post 3+ Months Ago

What PHP code can return "2008" (the current year)?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

http://www.php.net/date

PHP 5.1+
Code: [ Select ]
$year = date('o');


PHP < 5.1
Code: [ Select ]
$year = date('Y');
  • bastones
  • Novice
  • Novice
  • bastones
  • Posts: 19

Post 3+ Months Ago

Just as it states in the date() documentation, there are plenty of ways to display year as well as month, day, etc. Specifically for year you can use the following options:

  • y - 2 digit representation, (08)
  • y - and of course a 4 digit representation (2008)

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 138 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.