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
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 =

Link to comment
Share on other sites

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..

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.