Bitrix Site Manager

AddToTimeStamp

int
AddToTimeStamp(
 array add,
 int timestamp = false
)

The function AddToTimeStamp adds the specified time span to a date in Unix format.

Parameters

ParameterDescription
add Array containing the time span. The following keys are possible:
  • DD - days;
  • MM - months;
  • YYYY - years;
  • HH - hours;
  • MI - minutes;
  • SS - seconds.
timestamp Time value in Unix format to which the time span is to be added.
Optional; the current time is used by default.

Return Values

Returns the resulting date in the Unix format.

See Also

Example



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

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

// add 1 day, 1 month, 1 year, 1 min and 1 sec
$arrAdd = array(
	"DD"	=> 1,
	"MM"	=> 1,
	"YYYY"	=> 1,
	"HH"	=> 1,
	"MI"	=> 1,
	"SS"	=> 1,
);
$stmp = AddToTimeStamp($arrAdd, $stmp);

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