Connecting Tech Pros Worldwide Help | Site Map

getting month and year from a date

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 5th, 2006, 09:05 PM
laredotornado@zipmail.com
Guest
 
Posts: n/a
Default getting month and year from a date

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, 09:15 PM
Janwillem Borleffs
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.