Timestamp Calculations
I am using DataAssist and eCart to handle a user pass renewal system with php and MySQL. I am stuck with calculating dates and need some direction from a fellow member of the forum. I have been echoing the values on screen simply for testing purposes so that I can verify my math before doing the record update. My understanding is that using TimeStamp the dates are stored in seconds.
I need to be able to:
1) Calculate the new Expiry Date (in a format ready for record update to db schema table) NewActivationDate=TodaysDate+(NewPassLength+RemainingPassLength)
2) Calculate the days remaining in a Pass (display as whole number on screen for user)
After doing the calculations, I know how to do the update using DataAssist record update server behavior. That part is easy, allows additional control with session variables that the standard update record behavior does not have and it works.
With this code:
<?php
echo $row_WAATKtblmembers['passActivation'];
echo $row_WAATKtblmembers['passExpireDate'];
echo strtotime($row_WAATKtblmembers['passActivation']), "\n";
echo strtotime($row_WAATKtblmembers['passExpireDate']), "\n";
echo $_SESSION['ActivationPassLength'];
?>
Outputs to screen the following:
2009-09-01 00:00:00
2009-09-10 00:00:00
1251777600
1252555200
6
However, a simple math calc:
<?php
$datetoday = $_SERVER['REQUEST_TIME'];
$passExpireDate = $row_WAATKtblmembers['passExpireDate'];
$passDaysRemaining = ($passExpireDate - $datetoday);
echo $passDaysRemaining;
?>
I expected a positive value like 777600 however, it Outputs to screen the following negative value: -1252332020