views:

420

answers:

1

I'm having some issues getting phpdoc to run correctly. The docs are being generated for the most part successfully, but I get the following warning many times:

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 'America/Los_Angeles' for 'PST/-8.0/no DST' instead in /Users/ben/bin/PhpDocumentor/phpDocumentor/Converter.inc on line 5064

and

Warning: strftime(): 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 'America/Los_Angeles' for 'PST/-8.0/no DST' instead in PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/Smarty_Compiler.class.php on line 370

The Smarty warning I could easily remove from the code since it's just generating a timestamp at the top of the template in the rendered document. No biggie. The first error in the phpDocumentor I'm not sure about. Seems to be just assigning a date to Smarty for the template:

$templ->assign("date",date("r",time()));

Maybe I could just remove all the "date" variables in the Smarty templates and this line.

Anyway, this warning is in the generated docs as well and the index page just displays this warning. Any ideas what is happening here? I'm using version 1.4.3 and here are my flags/options:

#!/usr/bin/env bash
phpdoc \
    --title 'Asra Documentation' \
    --directory library/Asra \
    --target docs \
    --defaultcategoryname Asra \
    --defaultpackagename Asra \
    --quiet on \
    --output HTML:frames:phpedit
+5  A: 

This is PHP 5.3 at work. PHP 5.3+ demands that you set your timezone, for the reasons given (relying on the system settings is unsafe).

If you can, just call date_default_timezone_set() in your bootstrap/init/settings file. You can also specify it in an .htaccess file to make it a non-issue for your code, like this:

php_value date.timezone America/Vancouver
zombat
Yes, this is the exact reason.@Typeoneerror: It is a problem specific for PHP 5.3, not the PHP code you are actually using. You could have the same problem each time the code calls a PHP functions that uses the default timezone setting.
kiamlaluno
You guys rock. I just added a call to date_default.. in the phpdoc file. Fixed.
Typeoneerror
This happens with PHP 5.2 too, if your error_reporting is set to E_ALL | E_STRICT
djn
I had the same issue with PHPDocumentor, and this pointed me in the right direction. I was able to fix it by uncommenting and setting the timezone in `/etc/php.ini`: `date.timezone = 'America/Chicago'`This is probably the best solution if you have access to `php.ini`, live in the midwest, etc. etc.
jwhitlock