<?php
date_default_timezone_set("Spain/Madrid");
$date=date("H:i:s");
开发者_如何学JAVA
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?
Try
date_default_timezone_set("Europe/Madrid");
I typically use ini_set() :
ini_set('date.timezone', 'Europe/Madrid');
try Europe/Madrid
Take a look at http://www.php.net/manual/en/timezones.php
You'll find the list of the supported timezones in the documentation.
Here are the supported time zones in PHP
<?php
date_default_timezone_set('Europe/Madrid');
$date=date("H:i:s");
echo $date;
?>
精彩评论