note 59572 deleted from function.strtotime by derick

From: Date: Sun, 15 Jul 2007 12:44:42 +0000
Subject: note 59572 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128566@lists.php.net to get a copy of this message
Note Submitter: heinemann dot juergen at t-online dot de ---- An Example to use strtotime for calculat all days from weeks of this month <?php function DaysFromMonth( $t ) { // NOTE strtotime only works with english time format setlocale( LC_TIME, "en" ); $s = mktime( 0, 0, 0, date( "m", $t ), 1, date( "Y", $t ) ); $e = mktime( 0, 0, 0, date( "m", $t ), date( "t", $t ), date( "Y", $t ) ); // getting days from last month with strtotime at first week $f = strtotime( "-" . ( strftime( "%u", $s ) - 1 ) . " day", $s ); // getting days from next month with strtotime at last week $l = strtotime( "+" . ( 7 - strftime( "%u", $e ) ) . " day", $e ); $a = array(); foreach( range( $f, $l, 86400 ) AS $w ) { $a[date( "W", $w )][ strftime( "%u", $w ) ] = $w; } return $a; } function ConvertTime( &$i, $k ) { setlocale( LC_TIME, "de_DE" ); $i = strftime( "%A %e, %B %Y", $i ); } echo "<dl>"; foreach( DaysFromMonth( mktime() ) AS $k => $v ) { array_walk( $v, 'ConvertTime' ); echo "<dt>Woche:" . $k . "</dt><dd>" . implode( "</dd><dd>", $v ) . "</dd>"; } echo "</dl>"; ?>

« previous php.notes (#128566) next »