Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting Default Timezone - How?

Posted on 2014-03-01
2
Medium Priority
?
332 Views
Last Modified: 2014-03-04
I'm working on a 1and1 server and I'm getting this message on one of my calendar pages:

Strict Standards: strtotime(): 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 'EST/-5.0/no DST' instead in /homepages/42/d514133230/htdocs/adm/calendar_insert_execute.php on line 44

Strict Standards: 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 'EST/-5.0/no DST' instead in /homepages/42/d514133230/htdocs/adm/calendar_insert_execute.php on line 44

Strict Standards: strtotime(): 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 'EST/-5.0/no DST' instead in /homepages/42/d514133230/htdocs/adm/calendar_insert_execute.php on line 54

Strict Standards: 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 'EST/-5.0/no DST' instead in /homepages/42/d514133230/htdocs/adm/calendar_insert_execute.php on line 54

I put this in my header and I got the same error. What do I need to do to satisfy the system's concerns?

<?php
date_default_timezone_set('America/Chicago');
?>
0
Comment
Question by:brucegust
2 Comments
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 1000 total points
ID: 39898114
That is the correct way to set it.  It does have to be set on each and every page that uses any date or time functions.  And it needs to be at the top of the page before any of those functions are used.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 39898527
You should call 1and1 and tell them you want the default timezone settings placed in the php.ini file or the .htaccess file.  It is their responsibility to provide you with a working web server, and one that is spewing messages is not working correctly.  You should not be forced to modify every one of your scripts, even if you can do that.

With that said, here is how I create a web page.

<?php require_once('common.php');
/* REST OF THE CODE GOES HERE */

Open in new window

The common.php script contains all of the common elements that my site might require - it sets the error_reporting(), starts the session, establishes the data base connection, loads all of the functions and classes, etc.  If your scripts are all started with a common.php script, you have a one-line change to add the default timezone setting, and it will be in effect on every page.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question