Documentation

AddToTimeStamp

int
AddToTimeStamp(
 array add,
 int tmp = false
);

The function adds specified time interval to a date in Unix format. Returns new date also in Unix format.

Function parameters

ParameterDescription
add Array that describes the added time interval. The following keys for this array are available:
  • DD - days
  • MM - months
  • YYYY - years
  • HH - hours
  • MI - minutes
  • SS - seconds
tmp Time to which the time interval in Unix format to be added.
Optional parameter, current time by default.

See Also

Examples of use

$date = "07.04.2005 11:32:00";
echo "Original date: ".$date."<br>";

// obtain Unix timestamp from the specified date
$stmp = MakeTimeStamp($date, "DD.MM.YYYY HH:MI:SS");

// add Unix timestamp to the received result 
// 1 day, 1 year, 1 hour, 1 minute, 1 second and deduct 1 month
$arrAdd = array(
	"DD"	=> 1,
	"MM"	=> -1,
	"YYYY"	=> 1,
	"HH"	=> 1,
	"MI"	=> 1,
	"SS"	=> 1,
);
$stmp = AddToTimeStamp($arrAdd, $stmp);

// dispaly the result
echo "Result: ".date("d.m.Y H:i:s", $stmp); // 07.03.2006 12:33:01
?>


© «Bitrix24», 2001-2022
Up