Re: Calendar/Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-03-17 at 20:52 -0700, Jason Todd Slack-Moehrle wrote:
> Hi All,
> 
> Does anyone have code and/or advice for how to get get the current  
> week (with a passed current day, say) and what then end date is at  
> Saturday.
> 
> So take today: Tuesday March 17, 2009
> 
> I want to get:
> Sunday March 15, 2009
> Monday March 16, 2009
> Tuesday March 17, 2009
> Wednesday March 18, 2009
> Thursday March 19, 2009
> Friday March 20, 2009
> Saturday March 21, 2009

A sprinkle of math + a sprinkle of time + a sprinkle of PHP:

<?php

$dates = array();
$offset = (int)date( 'w' ) - 6;
for( $i = 0; $i < 7; $i++ )
{
    $dates[] = date( 'l F j, Y', strtotime( '+'.($offset + $i).'
days' ) );            
}
 
print_r( $dates );

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux