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. Link to comment https://forums.phpfreaks.com/topic/156878-solved-using-current-month-as-variable/ 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 Link to comment https://forums.phpfreaks.com/topic/156878-solved-using-current-month-as-variable/#findComment-826411 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 Link to comment https://forums.phpfreaks.com/topic/156878-solved-using-current-month-as-variable/#findComment-826416 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... Link to comment https://forums.phpfreaks.com/topic/156878-solved-using-current-month-as-variable/#findComment-826427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.