How to set date to my location?...">

How to set time in php?

<?php

date_default_timezone_set("Spain/Madrid");

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

echo $date;
?>

How to set date to my location?

I get this when I run the script Note: date_default_timezone_set () [function.date-default-timezone-set]: The timezone ID "Espana / Madrid" is not valid

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

+3
source share
7 answers

Try

date_default_timezone_set("Europe/Madrid");
+4
source

I usually use ini_set ():

ini_set('date.timezone', 'Europe/Madrid');
+2
source

Europe/Madrid

+1

.

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

Source: https://habr.com/ru/post/1755996/


All Articles