bob jomes bob jomes - 5 months ago 7x
PHP Question

Set timezone as Europe/London

I'm using PHP to insert a query into a database.

I am using

for each query, however currently it is returning a time which is 7 hours behind my timezone (Europe/London).

How do I set the timezone as Europe/London when I insert it into a MYSQL database?


Try the code below:

(I have written the code in PDO as you did not specify which extension you were using.)

  $time_stamp = date('Y-m-d H:i:s');
  $stmt = $con->prepare("INSERT INTO tablename (datetime) VALUES ('".$time_stamp."')");