Jump to content
Larry Ullman's Book Forums

Chapter 16 - Datetime Issue


Recommended Posts

I worked through the DateTime exercise in Chapter 16 and when I go to view the page all I get is a blank screen. So after reviewing my work, I took the script from the download section on this website and tried to view the page and got the same result. I have tried to view it using Chrome, Safari and Opera. I am not seeing any errors at all. Anyone else having this issue? Given it is happening with Larry's code as well as mine makes it seem like a configuration issue. Below is the result of viewing the source after trying to load the page. Any thoughts? It just stops at the <body> tag which is where the PHP scripts begins. Thanks in advance for any help.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>DateTime Usage</title>

<style type="text/css" media="screen">

body {

font-family: Verdana, Arial, Helvetica, sans-serif;

font-size: 12px;

margin: 10px;

}

label { font-weight: bold; }

.error { color: #F00; }

</style>

</head>

<body>

Link to comment
Share on other sites

Thanks...I have done it and got the following exception. Like I said before, this is with Larry's code which I find surprising. :-) I will take a crack at debugging this one now. Thanks for the suggestions.

 

Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): 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/Chicago' for 'CDT/-5.0/DST' instead' in /Users/DJ/Sites/PHPandMySQL/chapter16/datetime.php:20 Stack trace: #0 /Users/DJ/Sites/PHPandMySQL/chapter16/datetime.php(20): DateTime->__construct() #1 {main} thrown in /Users/DJ/Sites/PHPandMySQL/chapter16/datetime.php on line 20

Link to comment
Share on other sites

The Error message it's telling you exactly how to rectify the issue:

 

You are *required* to use the date.timezone setting or the date_default_timezone_set() function

 

http://php.net/manua...settimezone.php

 

I don't have this particular book, but I would be astonished if Larry hadn't mention this setting before the part of the book that uses this script, perhaps you missed it?

Link to comment
Share on other sites

Yep...I saw the solution in the error messages but wanted to figure it out myself instead of asking the forum. :-) Larry may have mentioned this earlier in his book, but I did upgrade to Mountain Lion halfway through this book and that resets all the PHP.ini settings as well as Apache settings. I may have set this before in the PHP.ini file and have since forgotten it until now. I did end up just using the date_default_timezone_set() function and it worked like a champ. I will likely have to go back and review my PHP.ini file settings now.

 

Thanks again for your assistance.

Link to comment
Share on other sites

 Share

×
×
  • Create New...