Warning: strtotime() [function.strtotime]: It is not safe to

Need help with the Administration of your Joomla! 1.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
sjn
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Jan 20, 2009 1:20 pm

Warning: strtotime() [function.strtotime]: It is not safe to

Post by sjn » Tue Jan 20, 2009 1:30 pm

I am a new user of Joomla, have completed installing it running on Open Solaris 2008.05.

Joomla 1.5.9 production/stable
php 5.26

I installed with no sample pages/data.

Now I want to begin administering a site.

Logged into the Front Page Manager, and the following message appears:

Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm in /opt/coolstack/apache2/htdocs/Joomla/libraries/joomla/utilities/date.php on line 56


I've looked through the Joomla site and googled, but I'm still unclear on what I need to do to eliminate this warning.

Can anybody tell me specifically, perhaps even step by step, where/how/what I need to change?

Thanks.

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19659
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by dhuelsmann » Tue Jan 20, 2009 1:39 pm

Per this http://ezpedia.org/wiki/en/ez/php5_technical_notes, the problem is probably in the server's php.ini file:

The solution is to set date.timezone in php.ini, if the TZ environment variable isn't set:

Code: Select all

[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/Brussels"
.. where "Europe/Brussels" was used as an example.

If you aren't the administrator of this site, you may need to communicate this information to him/her. I'd expect the admin does not see this, or it would have been fixed already.

If you can't get your administrator to fix the php.ini file, and if your host allows php directives in .htaccess, you can add this command to your .htaccess in Joomla root.

Code: Select all

php_value date.timezone yourServerTimeZone
where "yourServerTimeZone" is one of timezones listed here: http://php.net/manual/timezones.php

For example :

Code: Select all

php_value date.timezone Europe/Moscow
or
php_value date.timezone America/Chicago
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

sjn
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Tue Jan 20, 2009 1:20 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by sjn » Wed Jan 21, 2009 2:20 am

Ah, ok.. duh..

Thanks alot... fixed it :)

And nice to meet a Joomla master ....

I'm looking forward to seeing how well this can serve my needs.


Thanks again.

jamiesdomain
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Aug 11, 2009 11:15 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by jamiesdomain » Tue Aug 11, 2009 11:20 am

Hi there. I have the same problem but not really sure how to change it, can you help please.


The code for me should be "Europe/London" as im in the UK.

Code:
[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/London"

jamiesdomain
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Aug 11, 2009 11:15 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by jamiesdomain » Wed Aug 12, 2009 6:54 am

Well I seem to have fixed it, doing a complete uninstall then a reinstall and checked the php.ini file and it had the Code:

[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/London"


But now I cannot see menu items and getting theses error messages:

Warning: Parameter 4 to JHTMLMenu::treerecurse() expected to be a reference, value given in C:\xampp\htdocs\Joomla15\libraries\joomla\html\html.php on line 87

Warning: array_slice() expects parameter 1 to be array, null given in C:\xampp\htdocs\Joomla15\administrator\components\com_menus\models\list.php on line 143

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\Joomla15\administrator\components\com_menus\models\list.php on line 147

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\Joomla15\administrator\components\com_menus\views\list\view.php on line 65


I'am working to the Joomla! 1.5 Quick Start Guide. Anyone have any ideas?

jamiesdomain
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Aug 11, 2009 11:15 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by jamiesdomain » Wed Aug 12, 2009 7:04 am


cpthaddock
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Thu Jan 29, 2009 3:54 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by cpthaddock » Mon Aug 31, 2009 9:47 am

I've tried the patch, I've tried changing in php.ini

Neither is working. Any other solutions?

Edited to add:

When I added " " around Europe/City it worked just fine.

auntyfleen
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Sat Jun 27, 2009 10:21 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by auntyfleen » Mon Sep 21, 2009 10:09 am

Hello. The solution for me was that it was a compatibility issue (PHP 5.3 not being compatible with Joomla) See this post...
http://forum.joomla.org/viewtopic.php?p=1810330

User avatar
kazal
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Tue Jan 13, 2009 4:52 am
Location: Dhaka,Bangladesh.
Contact:

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by kazal » Sun Jan 17, 2010 11:24 am

Thanks for @"dhuelsmann" .
Its a gr8 solution for my server.
It works fine !!!!!!!!!!
:D :D :D :D :D :D

deevie
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Mar 02, 2010 10:03 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by deevie » Tue Mar 02, 2010 10:08 am

uh, in what file do i need to put this code in: php_value date.timezone Europe/Moscow?

the htacces or php.ini and where in the file..??

thanks,

User avatar
dhuelsmann
Joomla! Master
Joomla! Master
Posts: 19659
Joined: Sun Oct 02, 2005 12:50 am
Location: Omaha, NE
Contact:

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by dhuelsmann » Tue Mar 02, 2010 1:49 pm

dhuelsmann wrote:The solution is to set date.timezone in php.ini
Anywhere will work if it is not already there.
Regards, Dave
Past Treasurer Open Source Matters, Inc.
Past Global Moderator
http://www.kiwaniswest.org

circusflea
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Mar 07, 2010 4:32 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by circusflea » Sun Mar 07, 2010 4:35 pm

i know next to nothing about joomla and php and whatever :/
what exactly do i do to fix this problem?
like what progrrams do i use and stuff?

kanji2000
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Apr 04, 2008 8:26 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by kanji2000 » Mon Mar 15, 2010 11:03 pm

There is something wrong with the code itself.

Go to C:\xampp\htdocs\libraries\joomla\utilities\date.php

Line 52 creates a function called __construct. Notice how the underscore is too long. Highlight part of it and you'll see that it's actually two underscores. This is a mistake. Highlight one of the underscores and delete it. You should end up with _construct. Notice how the underscore is shorter?

Now save and reload.

Happy coding!!!

:D

andrisaick19
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Mar 17, 2010 3:59 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by andrisaick19 » Wed Mar 17, 2010 4:23 am

kanji2000 wrote:There is something wrong with the code itself.

Go to C:\xampp\htdocs\libraries\joomla\utilities\date.php

Line 52 creates a function called __construct. Notice how the underscore is too long. Highlight part of it and you'll see that it's actually two underscores. This is a mistake. Highlight one of the underscores and delete it. You should end up with _construct. Notice how the underscore is shorter?

Now save and reload.

Happy coding!!!

:D

Thanks Master, its fix my Problem :D :D "Two Tumbs Up"

TKM
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Thu Mar 18, 2010 6:24 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by TKM » Mon Mar 22, 2010 12:25 am

Did I do this right? I'm still getting the error.

Should also mention that when i ditched the underscore from constructs none of my links worked.

Edit: I compared a past php.ini with the changes i just made and they are identical.

What would happen if I took php.php, php.ini, and .htaccess from my remote site and pasted them into my localhost directories? My remote site works but my local site has this error, their must be something I can do.
You do not have the required permissions to view the files attached to this post.

kanji2000
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Apr 04, 2008 8:26 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by kanji2000 » Mon Mar 22, 2010 7:14 pm

TKM

Look at line 52. Notice how "__construct" has a very long underscore(__). There are actually two underscores. Delete only ONE of the underscores (_). The result should look like this

function _construct(

Notice how the underscore is now shorter. Save and reload.

As for the date.timezone = "America/Edmonton", just make sure that there is no semi-colon before that line of code.

TKM
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Thu Mar 18, 2010 6:24 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by TKM » Mon Mar 22, 2010 9:23 pm

kanji2000 wrote:TKM

Look at line 52. Notice how "__construct" has a very long underscore(__). There are actually two underscores. Delete only ONE of the underscores (_). The result should look like this

function _construct(

Notice how the underscore is now shorter. Save and reload.

As for the date.timezone = "America/Edmonton", just make sure that there is no semi-colon before that line of code.
Strangely, removing the the extra underscore disconnected all of my links. Removing both crashed the hole site. As per my last post, all it needed was a reboot, to recognize the change to date.timezone = "".

kanji2000
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri Apr 04, 2008 8:26 pm

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by kanji2000 » Mon Mar 22, 2010 9:42 pm

Ah, I see. So you removed only one underscore and it disconnected your links. That's not good. Sorry to hear that. Not sure why but it made all my error messages disappear. Weird. Time for more testing...

Happy Coding! :D

User avatar
xcronix
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Sun Oct 01, 2006 12:44 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by xcronix » Wed Apr 28, 2010 7:32 pm

kanji2000 wrote:There is something wrong with the code itself.

Go to C:\xampp\htdocs\libraries\joomla\utilities\date.php

Line 52 creates a function called __construct. Notice how the underscore is too long. Highlight part of it and you'll see that it's actually two underscores. This is a mistake. Highlight one of the underscores and delete it. You should end up with _construct. Notice how the underscore is shorter?

Now save and reload.

Happy coding!!!

:D
Thank You :) :D

moosh101
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Jul 30, 2008 6:56 am

Re: Warning: strtotime() [function.strtotime]: It is not safe to

Post by moosh101 » Wed Apr 28, 2010 10:05 pm

Greetings,

After installing the latest version of Joomla locally, I too experienced "Warning: date () [function.date]: It is not safe to Rely on the system's..." errors all over the screen. I tried the double underscore fix, but this killed the default links with 404 Page Not Found Errors, so I guess the double underscore is not a actually a bug after all.

I finally got it working (thanks to dhuelsmann) by editing the date.timezone line in the php.ini file (it was ;commented out) and this worked perfectly. If you are also experiencing this error, simply edit the date.timezone line in your php.ini file, or at least remove the ; comment at the start of the line. Don't forget to stop and restart the Apache server for the changes to take affect.

All the best,

Shane.

jeffschuler
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun May 09, 2010 5:00 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by jeffschuler » Sun May 09, 2010 5:11 pm

A class __construct() function should have 2 underscores.
See http://www.php.net/manual/en/language.oop5.decon.php

Do not change JDate's __construct(), as was suggested in kanji2000's post.

darko74
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Dec 03, 2009 9:45 am

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by darko74 » Mon May 17, 2010 7:41 pm

dhuelsmann wrote:Per this http://ezpedia.org/wiki/en/ez/php5_technical_notes, the problem is probably in the server's php.ini file:

The solution is to set date.timezone in php.ini, if the TZ environment variable isn't set:

Code: Select all

[Date]
; Defines the default timezone used by the date functions
date.timezone = "Europe/Brussels"
.. where "Europe/Brussels" was used as an example.

If you aren't the administrator of this site, you may need to communicate this information to him/her. I'd expect the admin does not see this, or it would have been fixed already.

If you can't get your administrator to fix the php.ini file, and if your host allows php directives in .htaccess, you can add this command to your .htaccess in Joomla root.

Code: Select all

php_value date.timezone yourServerTimeZone
where "yourServerTimeZone" is one of timezones listed here: http://php.net/manual/timezones.php

For example :

Code: Select all

php_value date.timezone Europe/Moscow
or
php_value date.timezone America/Chicago
Hey dhuelsmann! I had the same problem and your explanation helped me fix it. Just wanted to say thanks a lot!

Feemac
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Sun Feb 14, 2010 10:56 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by Feemac » Tue May 18, 2010 4:55 am

I had this error and have discovered one very important step that was mentioned in the passing. You must Stop/Start Apache in the XAMPP Control Panel. This fixed my problem, my php.ini file was alreaduy correct so there was no need to make any other alterations.

zorrocket
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu May 20, 2010 4:47 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by zorrocket » Thu May 20, 2010 4:50 pm

Hello,

I am having the same issue here, on a joomla site that is already online.

I use joomla 1.5.15 and the PHP environment is 5.3.2

I have tried both of the solutions suggested (htaccess and php.ini), but without success.

Can anybody think of something else to check or modify ?

Thanks in advance.

zorrocket
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu May 20, 2010 4:47 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by zorrocket » Thu May 20, 2010 5:34 pm

Allright, after double-checking with the server admin person, turned out the culprit WAS the php.ini file.

So this solution worked for me as well! :-)

symmetric
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Mon Jan 14, 2008 11:14 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by symmetric » Fri Jul 16, 2010 10:00 pm

Thanks!
FYI: To set PHP timezone on OSX Snow Leopard:
http://www.macosxhints.com/article.php? ... 1101932728

super-cube
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Jul 18, 2010 6:40 am

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by super-cube » Sun Jul 18, 2010 7:04 am

kanji2000 wrote:There is something wrong with the code itself.

Go to C:\xampp\htdocs\libraries\joomla\utilities\date.php

Line 52 creates a function called __construct. Notice how the underscore is too long. Highlight part of it and you'll see that it's actually two underscores. This is a mistake. Highlight one of the underscores and delete it. You should end up with _construct. Notice how the underscore is shorter?

Now save and reload.

Happy coding!!!

:D
This really works! Thanks so much :-) Ciao

super-cube
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Sun Jul 18, 2010 6:40 am

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by super-cube » Sun Jul 18, 2010 7:05 am

WOW - this really works, thanks so much :-)

luckymohan
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Jul 22, 2010 6:46 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by luckymohan » Thu Jul 22, 2010 6:50 pm

If none of the above solutions work for you,
try editing utilities/date.php file to include the following line.

putenv("TZ=America/New_York");


Ofourse inside <?php ?>.

njoy coding
Mohan

extremerony
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Aug 17, 2010 7:05 pm

Re: Warning: strtotime() [function.strtotime]: It is not saf

Post by extremerony » Tue Aug 17, 2010 7:13 pm

In my case I was using XAMPP server portable edition (Windows) and I just did the followings:

1. searched for php.ini file in the extracted files
2. After openning php.ini I using Ctrl+F searched for "[Date]"
3. I added the line bellow [Date]: date.timezone = "Asia/Dhaka"

After restarting Apache, the problem solved!


Locked

Return to “Administration 1.5”