When entering the variable to obtain the date, I am looking at the log that leaves it two hours before the current one in Spain.
$nowtimename = gmdate('Y-m-d h:i:s \G\M\T', time());
And I need it to be the one we use right now in Spain, not having to think that it is always two hours late, I suppose that adding a variable that adds two could be enough, but in case there is some way to do it in the gmdate
best way.
According to the PHP online manual ( http://php.net/manual/en/function.gmdate.php ) with the function
gmdate()
you cannot change the time zone:With the function
date()
it can be done as follows:I edit my answer because reviewing a little more thoroughly I have seen that the following can be done if you need to do it with the function
gmdate()
:Personally, I prefer the first option but it will depend on your needs.
You have to specify your time zone before generating the date.