I want to store in a variable the current time of Portugal and in another variable the current date of Portugal.
How can I do this?
I want to store in a variable the current time of Portugal and in another variable the current date of Portugal.
How can I do this?
You can do this:
date_default_timezone_set('Europe/Lisbon');
$dia = date('Y-m-d'); // 2016-12-24
$hora = date('G:i'); // 16:29
Note that in the demo, the time is not good, but should be because of the ideone platform.
Set date_default_timezone_set
to Europe/Lisbon
and see working here at ideone :
date_default_timezone_set('Europe/Lisbon');
$date = time();
$date = date('Y-m-d', $date);
$hour = date('H:i:s', $date);
echo "Data: ".$date."\n";
echo "Hora: ".$hour;
You can check the timezones support list in PHP .