Jump to content

I just need the currYear


nepzap2

Recommended Posts

Hello everyone,

 

I updated my version of php and since, a piece of code that always seemed to work no spits out the following 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 'America/New_York' for '-5.0/no DST' instead in C:\Abyss Web Server\htdocs\bti.cornell.edu\includes\home_news.php on line 13 

 

The simple code was the following:

 

<?php

$currYear = date("Y"); 

echo "<li><a href='index.php?page=NewsArchive&year=$currYear' class='moreInformation'>News Archive</a></li>"; 

?>

Link to comment
https://forums.phpfreaks.com/topic/250779-i-just-need-the-curryear/
Share on other sites

Thanks AyKay47

 

Below are my settings

 

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667

; http://php.net/date.default-longitude
;date.default_longitude = 35.2333

; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333

; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333

[filter]
; http://php.net/filter.default
;filter.default = unsafe_raw

; http://php.net/filter.default-flags
;filter.default_flags =

yes, you are receiving this error because your date.timezone directive is empty.. you will need to assign it the correct value in order to correctly use the date function..

 

;date.timezone = "America/New_York"

 

or whatever timezone you are in, alternatively, you can use date_default_timezone_set() to set the timezone of the executing page, however, this will need to be called on all of your pages and I would recommend chaning the php.ini directive to effect all of your pages..

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.