Skipjackrick Posted May 5, 2009 Share Posted May 5, 2009 Ok, so I am still a beginner with php but I'd like to know if there is a better way to do this. Currently, I am setting the following variables throughout my code. <?php $month=5; $month_name=May; $year=2009; ?> Is there a way that this could be done automatically? Each month I have to change the variables to the current month. Its a freaking pain in the ass. There has got to be a way to do this automatically. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 5, 2009 Share Posted May 5, 2009 <?php $date = getdate(); print_r($date); $month is $date['mon'], $month_name is $date['month'], and $year is $date['year']. =P Quote Link to comment Share on other sites More sharing options...
nankoweap Posted May 5, 2009 Share Posted May 5, 2009 dude... $year = date('Y'); $month = date('m'); $day = date('d'); edit... meant to post a link to the manual... http://www.php.net/manual/en/function.date.php Quote Link to comment Share on other sites More sharing options...
Skipjackrick Posted May 5, 2009 Author Share Posted May 5, 2009 <?php $date = getdate(); print_r($date); $month is $date['mon'], $month_name is $date['month'], and $year is $date['year']. =P Shoot, thanks fellas...That was easy... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.