Hi,
I need a way of getting the local systems time without setting timezone.
I use PHP in CLI on windows for scripting tasks. I need this script to write a log, and would like to write systems local date and time, without having to set the timezone.
If I don’t set the timezone, I get this warning:
Warning: date(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in C:\data\development\crons.php on line 2763
The code looks like this:
<?php define('WRITE_LOG', true); define('LOG_FILE', '.\\logfile.txt'); function echoTime($str) { $str = date('Y-m-d H:i:s').' '.$str."\r\n"; echo $str; if (WRITE_LOG) { if ($fp = fopen(LOG_FILE, 'a')) { fwrite($fp, $str); fclose($fp); } } } echoTime(‘Script started’); ?>Any ideas are more than welcome.