Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

date_default_timezone_set() Problem


Grok 🤖

Recommended Posts

Hello.

I have been developing a site on my personal webserver on my computer but today i went to make it live on the net but i am getting this error on my server but not on my personal webserver:

[quote]Fatal error: Call to undefined function: date_default_timezone_set() in /home/rpgsfind/public_html/site.php on line 72[/quote]

It's with this bit of code:
[code=php:0]
<?php
date_default_timezone_set("US/Eastern");

list($year, $mon, $day) = explode('-', $qry[4]);

$sevenDays = (7 * 24 * 60 * 60); // 604,800 seconds in 7 days
$entryTime = strtotime("$year-$mon-$day");
$now = strtotime("now");

if (($now - $entryTime) < $sevenDays)
{
echo "<img src='images/new.gif'>";
}
?>
[/code]

Why isn't it working on the live server, do i need to change something? any advice is welcome.

Thanks.

Peter.
Link to comment
https://forums.phpfreaks.com/topic/23404-date_default_timezone_set-problem/
Share on other sites

Make sure the PHP version you're using on the site is greater than or equal too Version 5.1.0

Create a file on the site called phpinfo.php and have it look like this:

[code]<?php
  phpinfo();
?>[/code]

When you run it, it should produce the info you're after.

Regards
Huggie
Yes, I'm afraid so.

If you look at the page in the manual for [url=http://uk.php.net/manual/en/function.date-default-timezone-set.php]date_default_timezone_set()[/url] you'll see it only works with versions later than 5.1.0

Regards
Huggie
There's no advantage of having php4 over php5, otherwise they wouldn't have released 5 :)

As for updating, as PHP6 development is well under way and PHP5 has been out for a long time, I'd say if you have the option to upgrade then do.  Unfortunately I don't have that option as I use hosted services as opposed to my own.

I'm sure others will come to the party and chip in their two cents if I've advised incorrectly though.

Regards
Huggie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.