Return to Snippet

Revision: 43916
at April 3, 2011 04:15 by aristoworks

Initial Code

function week_number( $date = 'today' ) 
    return ceil( date( 'j', strtotime( $date ) ) / 7 ); 



Usage Example:


$week_num = week_number();

$month = date("J", time());

echo "Today is the $week_num week of $month";


Initial URL

Initial Description
This simple function allows you to find a weeks position in the month based on a given date.  For instance I needed to alert the user their date was the "Second Week Of January" during a given month.  I may never use it again but it came in very handy for this particular project.

Initial Title
Find The Number Of A Week In A Month For A Given Date

Initial Tags
date, number

Initial Language