Solved

Setting Default Timezone - How?

Posted on 2014-03-01
2
310 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 82

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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses four methods for overlaying images in a container on a web page
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now