Connecting Tech Pros Worldwide Forums | Help | Site Map

getting month and year from a date

laredotornado@zipmail.com
Guest
 
Posts: n/a
#1: Mar 5 '06
Hello,

Using PHP 4, how would i Extract the numeric month and year from a date
variable created using the date() function?

Thanks, - Dave


Janwillem Borleffs
Guest
 
Posts: n/a
#2: Mar 5 '06

re: getting month and year from a date


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

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

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


JW


Closed Thread