getdate() error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

getdate() error

Post by lettie_dude »

Hi

Has anyone come across this error when using the getdate() function.

error occurred in pathtourl:getdate() [function.getdate]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable 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 'Europe/London' for 'BST/1.0/DST' instead.

The code is straight forward as below. I am only looking to get the current year nothing more nothing less!

Code: Select all

$currentdate = getdate();
$currentyear = $currentdate['year'];
I've looked on php.net to see if the function was now depricated but it mentions nothing about this error.

Any clues would be most helpful.

Cheers
User avatar
N1gel
Forum Commoner
Posts: 95
Joined: Sun Apr 30, 2006 12:01 pm

Post by N1gel »

I think this should get you the current year

Code: Select all

$currentyear = date("Y") //should give you the current year.
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

date()

Post by lettie_dude »

Same error I'm afraid.
lettie_dude
Forum Commoner
Posts: 65
Joined: Thu Dec 07, 2006 10:10 am

Resolved

Post by lettie_dude »

Apparently there has been a problem with getdate() and date() since php 5. The answer or work around however you want to look at it is here. Hope this helps someone else it's solved my problem.

http://uk.php.net/manual/en/function.da ... ne-set.php
Post Reply