Xtremer360 Posted September 4, 2012 Share Posted September 4, 2012 Which function do I need to get the current timestamp in GMT timezone. I need it to replace time(). if (strtotime($user_data->lock_date) > time()) Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/ Share on other sites More sharing options...
Pikachu2000 Posted September 4, 2012 Share Posted September 4, 2012 Did you read the manual? time Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375213 Share on other sites More sharing options...
requinix Posted September 4, 2012 Share Posted September 4, 2012 Timestamps are timezone-agnostic. It's the same number everywhere in the world. What timezones affect is how that timestamp is written as a string. Is $user_data->lock_date in GMT? Then date_default_timezone_set("GMT"); if (strtotime($user_data->lock_date) > time()) { Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375216 Share on other sites More sharing options...
Barand Posted September 4, 2012 Share Posted September 4, 2012 Timestamps are timezone-agnostic. It's the same number everywhere in the world. What timezones affect is how that timestamp is written as a string. Nothing to do with the current time setting on the server then? Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375223 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 I think it might be more accurate to say timestamps default to GMT Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375233 Share on other sites More sharing options...
kicken Posted September 4, 2012 Share Posted September 4, 2012 Nothing to do with the current time setting on the server then? The timezone setting in PHP affects how php interprets string dates (eg, strtotime()) and formatting, (eg date()) but has no bearing on the actual numeric timestamp that is returned. That number is always the same for any given time at any location, because it is, by definition, in GMT (# of seconds since 1/1/1970 @ 00:00:00 GMT). Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375244 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 Well this is confusing I"m trying to figure out why line 108 isn't sending the output array to be shown to the user. echo strtotime($user_data->lock_date); shows 1346794857 echo $current_gmt_time; shows 1346793958 so I don't know why it doesn't show that message http://pastebin.com/ETDGY5My Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375252 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 You haven't posted anything besides the if(){, we can't help without seeing the code. As soon as I hit submit, I saw the pastebin link. Looking at it now. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375256 Share on other sites More sharing options...
jazzman1 Posted September 4, 2012 Share Posted September 4, 2012 Well this is confusing I"m trying to figure out why line 108 isn't sending the output array to be shown to the user. echo strtotime($user_data->lock_date); shows 1346794857 echo $current_gmt_time; shows 1346793958 so I don't know why it doesn't show that message http://pastebin.com/ETDGY5My That's okay, but..... what about next statement : if (strtotime($user_data->lock_date) > $current_gmt_time) Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375259 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 Well this is confusing I"m trying to figure out why line 108 isn't sending the output array to be shown to the user. echo strtotime($user_data->lock_date); shows 1346794857 echo $current_gmt_time; shows 1346793958 so I don't know why it doesn't show that message http://pastebin.com/ETDGY5My That's okay, but..... what about next statement : if (strtotime($user_data->lock_date) > $current_gmt_time) What about it? I posted the two echoed amounts and not sure why it doesn't send the output array in that true statement. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375264 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 That's okay, but..... what about next statement : if (strtotime($user_data->lock_date) > $current_gmt_time) See line 98. $current_gmt_time = time(); Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375265 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 Can you add a die() on line 108 with the two variables, that will determine if the problem is the variables you're comparing, or with CI handling the output array. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375266 Share on other sites More sharing options...
jazzman1 Posted September 4, 2012 Share Posted September 4, 2012 Well this is confusing I"m trying to figure out why line 108 isn't sending the output array to be shown to the user. echo strtotime($user_data->lock_date); shows 1346794857 echo $current_gmt_time; shows 1346793958 so I don't know why it doesn't show that message http://pastebin.com/ETDGY5My That's okay, but..... what about next statement : if (strtotime($user_data->lock_date) > $current_gmt_time) What about it? I posted the two echoed amounts and not sure why it doesn't send the output array in that true statement. Exactly , 1346794857 is not greater than time() ! Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375267 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 Well this is confusing I"m trying to figure out why line 108 isn't sending the output array to be shown to the user. echo strtotime($user_data->lock_date); shows 1346794857 echo $current_gmt_time; shows 1346793958 so I don't know why it doesn't show that message http://pastebin.com/ETDGY5My That's okay, but..... what about next statement : if (strtotime($user_data->lock_date) > $current_gmt_time) What about it? I posted the two echoed amounts and not sure why it doesn't send the output array in that true statement. Exactly , 1346794857 is not greater than time() ! Yes it is. 1346794857 > 1346793958 Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375268 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 time() now is 1346795539 (fixed) So 1346794857 is no longer greater than time(). Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375270 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 Now I"m officially confused. Is my if statement wrong then? Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375271 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 Time has passed since then. At this point in time, according to your code, the user shouldn't be locked out any more. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375274 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 Which doesn't help me because my question was me not knowing why that output message isn't getting sent. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375275 Share on other sites More sharing options...
Jessica Posted September 4, 2012 Share Posted September 4, 2012 Well, I gave you a suggestion to debug it, you'll have to set the user's lock time to be in the future again if you want to test it. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375276 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 This is odd I did my five failed logins and everything posted correctly then tried logging in again and it gave me that same long message. I even put echo 'testing' inside of the if statement on 108 above the output array and it still echos true which means the message below is over ridding the output array on 108. Your account is currently locked, we appologize for the inconvienence. You must wait 15 minutes before you can login again! An email was sent to the owner of this account! Forgotten your username or password? <a href="forgotusername">Forgot Username</a> or <a href="forgotpassword">Forgot Password</a> Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375278 Share on other sites More sharing options...
Xtremer360 Posted September 4, 2012 Author Share Posted September 4, 2012 Any additional ideas? Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375288 Share on other sites More sharing options...
kicken Posted September 5, 2012 Share Posted September 5, 2012 The way your script is structured, it is not going to stop if your if (strtotime($user_data->lock_date) > $current_gmt_time) condition is true. It will set the output variable but then keep going and continue to process all the subsequent if statements. Assuming your putting in an invalid password rather than the correct one you'll end up triggering that section of code that locks the user out and displays that long message. If you put in the valid password you'd get logged in, even though the user is supposed to be locked out. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375329 Share on other sites More sharing options...
Xtremer360 Posted September 5, 2012 Author Share Posted September 5, 2012 I'm having a hard time understanding how to rewrite this submit function so that it'll execute properly. Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375342 Share on other sites More sharing options...
Jessica Posted September 5, 2012 Share Posted September 5, 2012 return Quote Link to comment https://forums.phpfreaks.com/topic/268000-gmt-timezone/#findComment-1375415 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.