Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

date_default_timezone_set causes fatal error when https

Posted on 2007-11-17
7
Medium Priority
?
2,857 Views
Last Modified: 2010-04-21
Have a problem with date_default_timezone_set(). It causes the following error when the code in question is called via https:

Fatal error: Call to undefined function: date_default_timezone_set() in /htdocs/timetest.php on line 2

This error can be reproduced even to having just enough to call it as in the snippet below. This is problematic as it causes non fatal errors in our code with that set line commented out. I could leave it that way but would like to find out how to fix it. The code is running at 1and1 shared server.
<?php
date_default_timezone_set('America/New_York');
?>

Open in new window

0
Comment
Question by:Stacy Spear
[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
  • 4
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 1500 total points
ID: 20305516
See http://www.php.net/manual/en/function.date-default-timezone-set.php The function was introduced with php 5.1.x and it seems you have an too old installation of php.
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20305532
has hernst42 said, only available in php5.

2 workarounds:
echo date('H:i:s', strtotime('+2 Hours')); add/subtract how many hours you need to get your time right

or
Place this once at the top of your script:
setlocale(LC_TIME, 'en_UK', 'english-uk', 'uk', 'eng'); // adjust accordingly

And then use strftime() to format the date.

Hope this helps.
0
 
LVL 23

Author Comment

by:Stacy Spear
ID: 20305565
I am quite familiar with when it came out. The top of my .htaccess is:

AddType x-mapp-php5 .php
AddType x-mapp-php5 .php5
AddType x-mapp-php4 .php4

And has been so for sometime. This code works in http, just not https.

Thanks for the pointer, just ran a phpinfo() via http and https. http is the proper 5.2.4, https on the other hand is 4.4.7. Strangest thing I've ever saw.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 23

Author Comment

by:Stacy Spear
ID: 20305572
I also want to state that this code ran great since January and just started giving errors Thursday. Maybe more info should have been given by me. :)

Going to call 1and1 to see what have they screwed up, unless you guys think my .htaccess can be changed, but I'm not aware of what to in this situation.
0
 
LVL 48

Expert Comment

by:hernst42
ID: 20305581
GUess the .htaccess is not used when run in https-mode. Guess the hoster misconfigured the server. Report the problem to their support.
0
 
LVL 23

Author Closing Comment

by:Stacy Spear
ID: 31409749
Made me think along other lines, which produced the solution, but still gave points.
0
 
LVL 23

Author Comment

by:Stacy Spear
ID: 20305726
Just for closure, 1and1 states that "PHP5 requires addhandler, not addtype" PHP5 and Apache are not the samething and Apache uses .htaccess. Oh well, that the add types to the following got it running again.

Addhandler x-mapp-php5 .php
Addhandler x-mapp-php5 .php5
Addhandler x-mapp-php4 .php4
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
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.
Suggested Courses

609 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