Jump to content
MakeWebGames

Recommended Posts

Posted

Hi all,

I have some code that basicly inputs start time and is supposed to + 16 hours then other functions use this to countdown to zero.

$rm = "0-".strtotime ("+57600");

The problem is that the time actually sets +9 hours instead. So it misses +7 hours which would make sense as the server time is GMT -7.

However whatever i try to correct this does not work. ("+57600") ("+16 hours") ("+16 hours gmt -7")

does anyone have an idea on how to solve this problem?

Thanks.

Posted

Re: strtotime produces wrong time.

 

$rm = "0-".strtotime ("+57600");

 

I'm not sure I understand that. It looks like you're taking the string 0- and concatenating a timestamp onto that.

Is the timestamp you're looking for supposed to be 16 hours ahead of "now"? If so, do this:

 

time() + 60 * 60 * 16
Posted

Re: strtotime produces wrong time.

I tried what you have posted but i cant get it to add the time to the sql. Infact it doesnt add the 0- either.

$rm_time = "0-".time () + 60 *60 * 16;

$result = mysql_query("UPDATE login SET newmail='0',rm='".my_real_escape_string($rm_time)."' WHERE name='" .mysql_real_escape_string($bo). "'")

or die(mysql_error());

Im not sure where im going wrong?

Posted

Re: strtotime produces wrong time.

After using that bit of sql i got this in the SQL. 57600 which is the time i need.

But i require the 0- before this.

 

The code below is how im working out the time.

 

$sql = "SELECT * FROM login WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'";

$query = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_object($query);

$rm_check = explode("-", $rm);

if(empty($rm_check[0])){

if((time() <= $rm_check[1]) ) {

$master = $rm_check[1] - time();

if ($master < 3600) {

echo date( "00:i:s", $rm_check[1] - time() );

}

if (($master > 3600) and ($master < 86400)){

echo date( "H:i:s", $rm_check[1] - time() - 3600 );

}

echo " before you are ready.";

}else{

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...