note 113492 added to function.time

From: Date: Fri, 18 Oct 2013 13:52:20 +0000
Subject: note 113492 added to function.time
Groups: php.notes 
Request: Send a blank email to php-notes+get-196584@lists.php.net to get a copy of this message
I built this function to get the strtotime numbers for the beginning and ending of the month and return them as arrays in an object. Cheers. //Returns values in the format of strtotime for evaluating purposes! function returnDateFirstAndLast($numberOfMonths) { $time=time(); $lastdayofcurrentmonth=strtotime('+1 month -1 day',strtotime(date('Y-m-1 24:59:59',$time))); $values=new stdClass(); for ( $i = 0;$i < $numberOfMonths;$i++ ) { $time=time(); $firstdayofmonth=strtotime('-'.$i.' month',strtotime(date('Y-m-1 00:00:00',$time))); $lastdayofmonth=strtotime('-'.($i - 1).' month -1 day',strtotime(date('Y-m-1 24:59:59',$time))); $first[$i]=$firstdayofmonth; if ( $i == 0 ) { $last[$i]=$lastdayofcurrentmonth; } else { $last[$i]=$lastdayofmonth; } } $values->first=$first; $values->last=$last; return $values; } ---- Server IP: 69.147.83.199 Probable Submitter: 72.240.127.33 ---- Manual Page -- http://php.net/manual/en/function.time.php Edit -- https://master.php.net/note/edit/113492 Del: integrated -- https://master.php.net/note/delete/113492/integrated Del: useless -- https://master.php.net/note/delete/113492/useless Del: bad code -- https://master.php.net/note/delete/113492/bad+code Del: spam -- https://master.php.net/note/delete/113492/spam Del: non-english -- https://master.php.net/note/delete/113492/non-english Del: in docs -- https://master.php.net/note/delete/113492/in+docs Del: other reasons-- https://master.php.net/note/delete/113492 Reject -- https://master.php.net/note/reject/113492 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196584) next »