How does one get the time in Php

Hi,

How does one gee the time in Php for 2 different time snap shots and then see how many minutes they are apart?

I tries this sample test, and it does not work:

	if (!isset($_SESSION['t1'])) {

	$_SESSION['t1'] = time();

	}

	echo '<p>Time 1 is: ' . $_SESSION['t1'];

//Note: this was added a few minutes after t1

	if (!isset($_SESSION['t2'])) {

	$_SESSION['t2'] = time();

	}

	echo '<p>Time 2 is: ' . $_SESSION['t2'];

	echo '<p>Time difference in Sec is: ' . ($_SESSION['t2'] - $_SESSION['t1']);

	echo '<p>Time difference in Min is: ' . (($_SESSION['t2'] - $_SESSION['t1']) / 60);

The above produces negative numbers which obviously are not right.

ThaNX,

Have you tried the datediff function
http://www.php.net/manual/en/datetime.diff.php

That function does not work, since I want to get from the machine the time that the users takes action X and then the time that they want to take action Y and then see the difference (in minutes) between these 2 actions.

wut

Maybe a variation of this
Check the comments
http://php.net/manual/en/function.time.php

Hi,

FYI, this works fine:

	if (!isset($_SESSION['t1'])) {

	$_SESSION['t1'] = $_SERVER['REQUEST_TIME'];

	}

	echo '<p>Time 1 is: ' . $_SESSION['t1'];



	$_SESSION['t2'] = $_SERVER['REQUEST_TIME'];