Ec (2); php Date and Time addition and subtraction ** & nbsp; * time addition operation & nbsp; * @ paramint $ increment & nbsp; * @ paramstring $ unit & nbsp; * @ paramstring $ time format returned by returnFormat & nbsp; * @ returnvoid & nbsp; * & nbsp; publicf script ec (2); script
Php Date and Time addition and subtraction
/**
* Time Addition
* @ Param int $ increment
* @ Param string $ unit
* @ Param string $ time format returned by returnFormat
* @ Return void
*/
Public function add ($ increment, $ unit ='s ', $ returnFormat = NULL ){
$ Increment = intval ($ increment );
$ Source = $ this-> timestamp;
Switch ($ unit)
{
Case 'yy': $ result = $ source + $ increment *
31536000; break; // year
Case 'mm': $ result = $ source + $ increment *
2592000; break; // month
Case 'dd': $ result = $ source ++ $ increment * 86400;
Break; // day
Case 'H': $ result = $ source + $ increment * 3600;
Break; // hour
Case 'M': $ result = $ source + $ increment * 60;
Break; // minute
Default: $ result = $ source + $ increment;
Break; // second
}
If ($ returnFormat ){
$ Result = $ this-> format ($ returnFormat, $ result );
}
Return $ result;
}