PHP Classes
elePHPant
Icontem

PHP handy date time handler: Compute dates and times of recurring events

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-07-15 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 140 All time: 8,491 This week: 609Up
Version License PHP version Categories
m8 1.0.0Custom (specified...5PHP 5, Time and Date
Description Author

This class can compute dates and times of recurring events.

It can take a given date and calculates the time that passed since that date in a configurable format.

The class can also get the next dates after now with a given interval period.

Recommendations

quarter wise, dates,
Braking the dates in quaters and calculating the number of days

Time that passed since timestamp
Calculate time passed from timestamp

I need to pick a date and return it to a form
I require the date to return in MySQL/Oracle format

What is the best PHP timer countdown class?
I need a php class that will countdown to 24 hours after a given

  Performance   Level  
Name: zinsou A.A.E.Mo´se is available for providing paid consulting. Contact zinsou A.A.E.Mo´se .
Classes: 20 packages by
Country: Benin Benin
Age: 27
All time rank: 20301 in Benin Benin
Week rank: 6 Up1 in Benin Benin Equal
Innovation award
Innovation award
Nominee: 3x

Details
Remorelap class is a simple class to handle Event recurrences but also time remained to
an event or time elapsed from an event .It provides a method to get in an array n occurences
of the event of your choice even beyond the unix timestamp limit.
Recurrence can be chosen in this set of choices
second,minute,hour,day,month,quartely,year so the choice is large.
You can also instead of an array of n occurences just get the nth occurence of a chosen event date.



class Remorelap{
	protected $chosendate,$chosendatetimestamp=0;
				public function __construct($date){
					$pattern="#^[0-9]{4}(-[0-9]{2}){2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}$#";//long but simple pattern to match
					if(is_string($date)&&preg_match($pattern,$date)){
						
						if($arrdate[2]<=31&&$arrdate[2]>=1&&$arrdate[1]<=12&&$arrdate[1]>=1&&$arrdate[0]>=1970&&$arrdate[0]<=2037
						&&$artime[0]<=23&&$artime[0]>=0&&$artime[1]<=59&&$artime[1]>=0&&$artime[2]<=59&&$artime[2]>=0){
						
							return true;
						}else{
							echo"<br>Bad date format<br> ";
							return false;
						}
											
					}else{
						echo"<br>Bad date format<br> ";
						return false;
					}
				}

				public function ago(){
					$time=time();
					$timeago=$time-$this->chosendatetimestamp;
					if($timeago>=0){
						$TIMEAGO=$y." year(s) ".$d." day(s) ".$h." hour(s) ".$min." minute(s) and ".$sec." second(s)";
						return $TIMEAGO." elapsed<br>";
					}else{
						return false;
					}
					
				}

				public function remained(){
					$time=time();
					$timeago=$this->chosendatetimestamp-$time;
					if($timeago>=0){
						$TIMEAGO=$y." year(s) ".$d." day(s) ".$h." hour(s) ".$min." minute(s) and ".$sec." second(s) ";
						return $TIMEAGO." remained<br>";
					}else{
						return false;
					}
					
				}

				public function recurrence($interval,$nth=0){
					if(is_array($interval)&&count($interval)==1){
						$nth=($nth<=0)?1:$nth;
						foreach($interval as $key=>$value){
							$k=$key;
							$v=$value;
						}
						if(is_integer($v)){
							switch($k){
								case "s":
									
								break;
								case "i":
									
								break;
								case "h":
									
								break;
								case "d":
									
									
								break;
								case "w":
									
								break;
								case "m":
									
								break;
								case "q":
									
								break;
								case "y":
								break;
								default:
								break;
							}
							
							
							
						}else{
							return false;
						}
					}else{
						return false;
					}
				}

				public function nthrecurrence($interval,$nth=0){
					if(is_array($interval)&&count($interval)==1){
						$nth=($nth<=0)?1:$nth;
						foreach($interval as $key=>$value){
							$k=$key;
							$v=$value;
						}
						if(is_integer($v)){
							switch($k){
								case "s":
									
								
								break;
								case "i":
									
								break;
								case "h":
									
								break;
								case "d":
									
								break;
								case "w":
									
								break;
								case "m":
									
								break;
								case "q":
									
								break;
								case "y":
									
								break;
								default:
								break;
							}
							
							
							
						}else{
							return false;
						}
					}else{
						return false;
					}
				}
				
				
				public function get_timestamp(){
					return $this->chosendatetimestamp;
				}
				
				public function get_chosendate(){
					return $this->chosendate;
				}
				public function format_chosendate($format){
					return date($format,$this->chosendatetimestamp);
				}

}



For a how to use example see the testremorlap.php file and for more questions or bug reporting
or simply feedback rate this classe and use the dedicated forum at PHPclasses.org or simply contact
me at leizmo@gmail.com
  Files folder image Files  
File Role Description
Accessible without login Plain text file license Lic. license
Accessible without login Plain text file readme Doc. readme
Accessible without login Plain text file testremorlap.php Example example script
Plain text file timeremorelap.class.php Class class source

 Version Control Unique User Downloads Download Rankings  
 0%
Total:140
This week:0
All time:8,491
This week:609Up