Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMayur Pande
Courses Plus Student 11,711 PointsConverting timezone retrieved from mysql db using go daddy
In my php code I have the date default time zone set to;
date_default_timezone_set('Europe/London');
However as I am using godaddy as my host, they have their timezone's set to UTC -6:00 hours.
I have data that is stored in the db i.e. current timestamp for password reset function. How would I go about converting this time into the correct.
Would I simply just add 6:00 hours?
Here is what my code looks like
public function get_token($email,$token){
$email = mysqli_real_escape_string($this->link, $email);
$token = mysqli_real_escape_string($this->link, $token);
$result = mysqli_query($this->link, "select email, token, expirytime from user where email = '{$email}'");
$row = mysqli_fetch_assoc($result);
$time = strtotime($row['expirytime']);
$curtime = time();
$userResetDets = array(
'email' => $row['email'],
'token' => $row['token']
);
if($token === $row['token'] && (($curtime-$time) < 3600)){
return $userResetDets;
}else{
$res = mysqli_query($this->link,"update user set token='' and expirytime='' where email = '{$email}'");
return null;
}
}