Date issue


I’ve just upgraded from 1.5.1 which was running fine, and since the upgrade to 1.6, once logged in, all I get presented with is a date error, specifically:

Date format must be: YYYY-MM-DD, or ‘today’ or ‘yesterday’ or any keyword supported by the strtotime function (see PHP: strtotime - Manual for more information)

The backtrace reads:


#0 /usr/local/www/httpdocs/piwik/html/core/Controller.php(98): Piwik_Date::factory('now', 'Europe/London')
#1 /usr/local/www/httpdocs/piwik/html/plugins/MultiSites/Controller.php(55): Piwik_Controller->getDateParameterInTimezone('today', 'Europe/London')
#2 /usr/local/www/httpdocs/piwik/html/plugins/MultiSites/Controller.php(37): Piwik_MultiSites_Controller->getSitesInfo()
#3 [internal function]: Piwik_MultiSites_Controller->index()
#4 /usr/local/www/httpdocs/piwik/html/core/FrontController.php(132): call_user_func_array(Array, Array)
#5 /usr/local/www/httpdocs/piwik/html/index.php(53): Piwik_FrontController->dispatch()
#6 {main}

This is running on a FreeBSD 8.1 box.

Any help / info regarding this greatly appreciated.



Is your server datetime set correctly?

If I’m correct this error could only happen if the server datetime is off by many years… otherwise I don’t really understand how it would happen!

Hi Matt…

Yup, everything correct…

Ian@morris:~ $ date
Tue Oct 18 20:42:52 BST 2011

Ian@morris:~ $ php -v
PHP 5.3.8 with Suhosin-Patch (cli) (built: Sep  2 2011 23:14:49)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with NuSphere PhpExpress v3.0.1, Copyright (c) 2002-2010 NuSphere Corp, by Dmitri Dmitrienko

This wasn’t an issue in 1.4, 1.5 and 1.5.1. I’ve tried both updating (overwriting) files and using a clean install of files, both result in the same error.



Can you comment out line 87 as follows in core/Date.php

if($timestamp < 681436800 // can't be doing web analytics before the 1st website
			|| $timestamp > 7289049600 // piwik is designed to last (date lib will break long before that)
		) {
			//throw $invalidDateException;

Hi Matt…

That works.

I did try various debugging previously, but all of the date strings coming into that method seem to be as expected.

I’m happy to hack some of the code if you want me to try some other things too :slight_smile:



Hi Matt…

Sorted it :smiley:

Here’s a patch for you:

--- _Date.php   2011-10-09 16:39:35.000000000 +0100
+++ Date.php    2011-10-18 23:29:23.000000000 +0100
@@ -82,7 +82,8 @@
                $timestamp = $date->getTimestamp();
                if($timestamp < 681436800 // can't be doing web analytics before the 1st website
-                       || $timestamp > 7289049600 // piwik is designed to last (date lib will break long before that)
+                        // Value below reduced to run on 32-bit boxes
+                       || $timestamp > 2147483647 //7289049600 // piwik is designed to last (date lib will break long before that)
                ) {
                        throw $invalidDateException;

‘7289049600’ is too large an INT for 32-bit boxes… the timestamp was always reporting being greater than that value.

HTH :slight_smile:



EDIT: Although… just remembered that my server is 64-bit anyway… PHP_INT_MAX returns ‘9223372036854775807’… so not sure what’s going on there. Either way, the above patch has fixed the issue for me anyway.

Great thanks for the fix!

I still have that issue after upgrading from 1.5.2 to 1.6. Somebody else ran the upgrade without asking me first and ran the update script by browser I guess - But I do not know if the script had completed back then. I then ran CoreUpdater by shell but I got no output. I also checked the source code and verified that the patches 4581 and 5333 are enclosed.

After sending the login form I land on
showing the error

Any hints?

do you have this changeset applied?

if yes, then the problem would be because your server data time is off by many years… ?

Thanks for a quick response.

Patch 5333 was already applied.

data off may years?
It is just 24h offline now and statistic data was last generated less a week ago by browser. (no cron)

I changed core/Date.php for some debugging…

And I get:

followed by the error message

So the timestamp is 0.

here the backtrace:

I looked in the database for some piwik options…

Looks good for me.

Any hints for me what to do next to solve the problem?

For some unknonwn reasons, it looks like your table piwik_site contains a wrong entry for “ts_created”

  1. UPDATE the row and set the creation date, for example set it to 1284854545
  2. to check if there is a bug in piwik, create a new website in Settings >WEbsites.
    is the field ts_created for the newly created website in piwik_site correct ?

Thanks Matt!

You were right. The ts_created was 0.

I’ve updated the ts_created fields with the values from a backup. And now it’s working again.

I don’t know who/how they were set to 0.

I also created a new site to check your “2)” - everything is fine - the ts_created got set.

May I pay you a pizza? :wink:


I have 2 versions running on different directory… i.e 1.5.1 and 1.6. I am having issues with date. Default my date is set to next day. I cannot click on today or previous day. Whereas i can change the daterange to week or monthly or year… But i cannot see my hits(access)…

Can you please help me? Thanks.

I am all set. I think it was timezone issue.