Page 1 of 3

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

Posted: Tue Jan 20, 2009 1:30 pm
by sjn
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.

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

Posted: Tue Jan 20, 2009 1:39 pm
by dhuelsmann
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

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

Posted: Wed Jan 21, 2009 2:20 am
by sjn
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.

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

Posted: Tue Aug 11, 2009 11:20 am
by jamiesdomain
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"

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

Posted: Wed Aug 12, 2009 6:54 am
by jamiesdomain
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?

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

Posted: Wed Aug 12, 2009 7:04 am
by jamiesdomain

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

Posted: Mon Aug 31, 2009 9:47 am
by cpthaddock
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.

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

Posted: Mon Sep 21, 2009 10:09 am
by auntyfleen
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

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

Posted: Sun Jan 17, 2010 11:24 am
by kazal
Thanks for @"dhuelsmann" .
Its a gr8 solution for my server.
It works fine !!!!!!!!!!
:D :D :D :D :D :D

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

Posted: Tue Mar 02, 2010 10:08 am
by deevie
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,

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

Posted: Tue Mar 02, 2010 1:49 pm
by dhuelsmann
dhuelsmann wrote:The solution is to set date.timezone in php.ini
Anywhere will work if it is not already there.

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

Posted: Sun Mar 07, 2010 4:35 pm
by circusflea
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?

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

Posted: Mon Mar 15, 2010 11:03 pm
by kanji2000
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

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

Posted: Wed Mar 17, 2010 4:23 am
by andrisaick19
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"

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

Posted: Mon Mar 22, 2010 12:25 am
by TKM
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.

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

Posted: Mon Mar 22, 2010 7:14 pm
by kanji2000
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.

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

Posted: Mon Mar 22, 2010 9:23 pm
by TKM
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 = "".

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

Posted: Mon Mar 22, 2010 9:42 pm
by kanji2000
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

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

Posted: Wed Apr 28, 2010 7:32 pm
by xcronix
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

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

Posted: Wed Apr 28, 2010 10:05 pm
by moosh101
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.

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

Posted: Sun May 09, 2010 5:11 pm
by jeffschuler
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.

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

Posted: Mon May 17, 2010 7:41 pm
by darko74
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!

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

Posted: Tue May 18, 2010 4:55 am
by Feemac
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.

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

Posted: Thu May 20, 2010 4:50 pm
by zorrocket
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.

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

Posted: Thu May 20, 2010 5:34 pm
by zorrocket
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! :-)

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

Posted: Fri Jul 16, 2010 10:00 pm
by symmetric
Thanks!
FYI: To set PHP timezone on OSX Snow Leopard:
http://www.macosxhints.com/article.php? ... 1101932728

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

Posted: Sun Jul 18, 2010 7:04 am
by super-cube
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

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

Posted: Sun Jul 18, 2010 7:05 am
by super-cube
WOW - this really works, thanks so much :-)

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

Posted: Thu Jul 22, 2010 6:50 pm
by luckymohan
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

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

Posted: Tue Aug 17, 2010 7:13 pm
by extremerony
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!