5
I intend to store in a variable the current time of Portugal and in another variable the current date of Portugal.
How can I do?
5
I intend to store in a variable the current time of Portugal and in another variable the current date of Portugal.
How can I do?
3
You can do it like 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 demonstration, the time is not right, but must be because of the ideone platform.
1
Configure the date_default_timezone_set
for Europe/Lisbon
and see working here in 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 Time Zones support list here in the documentation of PHP.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.