Solved

Setting Default Timezone - How?

Posted on 2014-03-01
2
323 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 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 110

Accepted Solution

by:
Ray Paseur earned 250 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

631 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