Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Date Warning in My First PHP Code

When running the following code:

  <p>&copy;<?php echo date('Y'); ?> Shirts 4 Mike</p>

I get the following error: \Warning: date() [function.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/New_York' for 'EDT/-4.0/DST' instead...

Any ideas?

2 Answers

For those who encounter this error, the easiest fix is to put the following line into /etc/php.ini:

date.timezone = America/New_York

If you need to find the correct timezone for your locale, click http://php.net/manual/en/timezones.php

It's letting you know the local timezone is not set when using date(). Depending on your error reporting settings you will recieve error messages when PHP notices things that it doesn't agree with.

Check the Errors/Exceptions section for date() in the PHP Manual.

date_default_timezone_set()

Error Reporting

Sean, thanks for your help; it took a bit of digging, but I found an easy solution, noted above.