Connecting Tech Pros Worldwide Help | Site Map

getting month and year from a date

  #1  
Old March 5th, 2006, 10:05 PM
laredotornado@zipmail.com
Guest
 
Posts: n/a
Hello,

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

Thanks, - Dave

  #2  
Old March 5th, 2006, 10:15 PM
Janwillem Borleffs
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing month and year from a timestamp gregerly answers 0 January 7th, 2009 08:10 PM
Date Conversion Problem Greg (codepug@gmail.com) answers 4 August 15th, 2008 01:15 AM
Not getting current date in calendar using strtotime cassbiz answers 2 January 18th, 2007 05:39 AM
covert time from date Hour min sec format to epoch time i.e time since 1 jan 1970 in C Summu82 answers 5 June 7th, 2006 03:55 PM