View Single Post

  #2 (permalink)  
Old 03-05-2006
Janwillem Borleffs
 
Posts: n/a
Default Re: getting month and year from a date

laredotornado@zipmail.com wrote:
> Using PHP 4, how would i Extract the numeric month and year from a
> date variable created using the date() function?
>


With date:
list($year, $month) = explode('-', date('Y-n'));

With getdate:
$date = getdate();
$year = $date['year'];
$month = $date['mon'];


JW


Reply With Quote