server time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • canabatz
    New Member
    • Oct 2008
    • 155

    server time

    hi all ,im runing a timer on auction site and any product got his ending time ,i want to have an automatic rule to have 30 minutes more to an auction if the time was ended ,i want to update the server with the new date and to have the current time +30 minutes!!

    this is what i got this far:

    Code:
    <?	$dt=time();
    	echo $date=date('Y-m-d H:i:s',$dt);?>
    <?
    					  
    if ($rem < 11 && $expire_date=$expire_date){
    
    $sql_update_time="update bidding_main set expire_date = '$date' where bid_id='$bid_id'";
    mysql_query($sql_update_time)or die(mysql_error());}
    			?>
    when im runing this code the expire_date is geting the new date and time!

    what i need to do to had 30 minutes more to the timer?

    thanx!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    You should update the date in the database. It's just going to create problems.

    A better way would be to define this 30 minute margin somewhere, and add it to the date in the database when it is used.

    By that I mean, wherever you use that date, just add 30 minutes to it.
    For example:
    [code=php]
    $expires = strtotime("From your database"); // The date as a Unix timespamp
    $current = time(); // Current Unix timestamp
    $margin = (60 * 30); // 30 minute margin in seconds

    if($expires <= $current)
    {
    if(($expires + $margin) <= $current) {
    echo "Sorry. All the time is up.";
    }
    else {
    echo "Time is up, but you get 30 extra minutes!";
    }
    }
    else {
    echo "Plenty of time left";
    }[/code]
    Get my meaning?

    Comment

    Working...