I made a code that print a log in a server folder, this log return also a date with hours but the server isn't in my Nation so the hours is incorrect for me. Actually this is my code:
$now = new DateTime();
$aggiornata = "\r\n" . "Aggiornamento eseguito con successo per: " . $value['caption'] . " DATA: " . $now->format('d-m-Y H:i:s');
file_put_contents(getenv('OPENSHIFT_REPO_DIR').'php/log.txt', $aggiornata, FILE_APPEND);
How to set the correct hour for Italy?
look at DateTimeZone
$date = new DateTime('now',new DateTimeZone("Europe/Rome"));
You can also do it at the top of of your file like for example:
date_default_timezone_set('Europe/Rome');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With