bob jomes bob jomes - 1 year ago 84
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?

Answer Source

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."')");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download