?
Solved

date_default_timezone_set causes fatal error when https

Posted on 2007-11-17
7
Medium Priority
?
2,849 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Imagine a situation that you have installed SSL (http://en.wikipedia.org/wiki/Secure_Sockets_Layer) Certificate on your Cisco ASA (Cisco Adaptive Security Appliance) firewall. Installation of SSL certificate on ASA is an another topic for which you …
The viewer will learn how to count occurrences of each item in an array.
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…
Suggested Courses

752 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