note 96013 deleted from function.date by danbrown

From: Date: Wed, 03 Feb 2010 11:51:20 +0000
Subject: note 96013 deleted from function.date by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165619@lists.php.net to get a copy of this message
Note Submitter: eamon at gizzle dot co dot uk ---- To Find the real month is something that can annoy some of us. here's a function to make this easier. print_r( realmonth('2010-05-01 19:30:00') ); function realmonth($date) { // current time $time = strtotime($date); // current time info $currentTimeInfo = (object)getdate($time); // the week difference $weeks = (4 * 7 * 24 * 60 * 60); $nextTime = date("Y-m-d H:i:s",($time + $weeks)); // compare the dates $date = (object)array( 'start' => $currentTimeInfo, 'end' => (object)getdate(strtotime($nextTime)) ); if($date->start->mon == $date->end->mon) { $nextTime = date("Y-m-d H:i:s",($time + $weeks + (7 * 24 * 60 * 60))); } return (object)array( 'start' => $currentTimeInfo, 'end' => getdate(strtotime($nextTime)) ); } Result: stdClass Object ( [start] => stdClass Object ( [seconds] => 0 [minutes] => 30 [hours] => 19 [mday] => 1 [wday] => 6 [mon] => 5 [year] => 2010 [yday] => 120 [weekday] => Saturday [month] => May [0] => 1272738600 ) [end] => Array ( [seconds] => 0 [minutes] => 30 [hours] => 19 [mday] => 5 [wday] => 6 [mon] => 6 [year] => 2010 [yday] => 155 [weekday] => Saturday [month] => June [0] => 1275762600 ) ) Thanks Eamon Straughn

« previous php.notes (#165619) next »