Solved

date_default_timezone_set causes fatal error when https

Posted on 2007-11-17
7
2,834 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
  • 4
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

#SSL #TLS #Citrix #HTTPS #PKI #Compliance #Certificate #Encryption #StoreFront #Web Interface #Citrix XenApp
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
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…
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.

856 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