tags:

views:

66

answers:

7
<?php

date_default_timezone_set("Spain/Madrid");

$date=date("H:i:s");

echo $date;
?>

how can i set the date to my location?

i get this when i run the script Notice: date_default_timezone_set() [function.date-default-timezone-set]: Timezone ID 'Espana/Madrid' is invalid

i know Spain/Madrid is not recognized, but how can i fix it?

+1  A: 

try Europe/Madrid

jigfox
thank you! it works now
Petre
+2  A: 

Try

date_default_timezone_set("Europe/Madrid");
zahstra
+1  A: 

Take a look at http://www.php.net/manual/en/timezones.php

Samuel
+1  A: 

You'll find the list of the supported timezones in the documentation.

Macmade
A: 
<?php
   date_default_timezone_set('Europe/Madrid');
   $date=date("H:i:s");
   echo $date;
?>
Bakhtiyor
+1  A: 

I typically use ini_set() :

ini_set('date.timezone', 'Europe/Madrid');
joshtronic