Im trying to figure out why i'm getting the wrong time, this is my code:
date_default_timezone_set("Europe/Amsterdam"); //Use the time of amsterdam
$date = new DateTime();
$date->modify("+".$tijd." minutes"); //Add the time in minutes to current time.
$datum = $date->format('Y-m-d H:i:s');
So when $tijd is set to 10, $datum returns this: 2015-02-28 14:49:00 But in Amsterdam the time is 14:10 at the moment (around that). So it should give something like 2015-02-28 14:20:00.
So what am i doing wrong since this is kinda weird, Thanks in advance!
EDIT: This is my full-code: public function jail($tijd, $id){
date_default_timezone_set("Europe/Amsterdam"); //Use the time of amsterdam
$date = new DateTime();
$date->modify("+".$tijd." minutes"); //Add the time in minutes to current time.
$datum = $date->format('Y-m-d H:i:s');
$conn = $this->conn;
$jail = $conn->prepare('UPDATE gebruikers
SET jail = :jail
WHERE id = :id');
$uitvoeren = $jail->execute(array(
':jail' => $datum,
':id' => $id));
if($uitvoeren){
return true;
} else {
return false;
}
}
And then in another PHP file:
$user = new user;
$tijd = 10;
$id = 1;
$gevangenis = $user->jail($tijd, $id);
if($gevangenis){
echo 'Gelukt!';
} else {
echo 'Mislukt!';
}