Jump to content


Photo

date_default_timezone_set() Problem


  • Please log in to reply
6 replies to this topic

#1 wwfc_barmy_army

wwfc_barmy_army
  • Members
  • PipPipPip
  • Advanced Member
  • 320 posts

Posted 09 October 2006 - 08:53 AM

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:

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


It's with this bit of code:
<?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'>";
}
?>

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

Thanks.

Peter.

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 09 October 2006 - 09:02 AM

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:

<?php
   phpinfo();
?>

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

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 wwfc_barmy_army

wwfc_barmy_army
  • Members
  • PipPipPip
  • Advanced Member
  • 320 posts

Posted 09 October 2006 - 09:11 AM

Thanks for your reply i have version PHP Version 4.4.3. Is this the problem?

Thanks.

Peter.

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 09 October 2006 - 09:13 AM

Yes, I'm afraid so.

If you look at the page in the manual for date_default_timezone_set() you'll see it only works with versions later than 5.1.0

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 wwfc_barmy_army

wwfc_barmy_army
  • Members
  • PipPipPip
  • Advanced Member
  • 320 posts

Posted 09 October 2006 - 09:15 AM

Ah, so whats the advantage of having php 4 over php 5 and is there a reason i shouldn't update?

Thanks.

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 09 October 2006 - 09:18 AM

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
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 wwfc_barmy_army

wwfc_barmy_army
  • Members
  • PipPipPip
  • Advanced Member
  • 320 posts

Posted 09 October 2006 - 09:20 AM

Thanks for your advice HuggieBear. :)

Thanks.

Peter.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users