DMXzone Calendar 2 Support Product Page


Setting an initial date greater then about 25 years

Asked 09 Mar 2012 02:30:55
has this question
09 Mar 2012 02:30:55 Terrel Pochert posted:
I pick a date greater then about 25 years (ie, 2040-03-08). It saves it in a MySQL database correctly, but when trying to use this field as the initial date in Calendar2, it displays it as 1969-12-31. If I use a date less then about 25 years in the future it works correctly. Everything "seems" to work just great as long as I don't set a date greater then about 25 years into the future. If I use a plain old date field with the MySQL, it works great... so I don't think I have a problem with the database. Any thoughts?


Replied 09 Mar 2012 07:43:17
09 Mar 2012 07:43:17 Vulcho Vulev replied:
Hello Terry.

From the user interface of the extension click under "advanced" tab . In "Elements & Navigation" apply the check box for "Year" , then edit Year range field:

c-10:c+10 should become for example c-10:c+30 (if you want to display events till 2042).

Regards: Vulcho.
Replied 09 Mar 2012 12:10:37
09 Mar 2012 12:10:37 Terrel Pochert replied:
Yes, the c+30 does allow picking the original date correctly and recording it in the MySQL database correctly, BUT when trying to "update" or reload that same date back into Calendar2 it displays it as 1969-12-31 even though dates less then about 2030 work just fine. It's the updating or "reloading" a date back into Calendar2 that seems to be the problem with dates larger then 25 years into the future.
Replied 09 Mar 2012 13:44:24
09 Mar 2012 13:44:24 Vulcho Vulev replied:
Hello Terry.

This is a issue related with the way how php store dates to MySQL Databases.Please read the work around bellow:

Prevent PHP date() from defaulting to 12/31/1969

I am using a MySQL database with PHP. I store my date values in the database using the DATETIME field.

I'm using this PHP code to convert inputted dates to the appropriate format for MySQL.
date("Y-m-d H:i:s", strtotime($inputDate))

However, whenever a date is invalid, it is placed in the database as
1969-12-31 19:00:00

Is there a way to default this to
0000-00-00 00:00:00 


Just detect validity with the output of strtotime(), which returns false on failure.

Something like:
$time = strtotime($inputDate);
$date = ($time === false) ? '0000-00-00 00:00:00' : date('Y-m-d H:i:s', $time);


strtotime is returning false which date evals as 0. Before you should check that strtotime is not returning false to prevent that:

$ts = strtotime($inputDate);

if ($ts === false)
//invalid date
echo date("Y-m-d H:i:s", $ts);

Regards: Vulcho
Replied 09 Mar 2012 15:12:59
09 Mar 2012 15:12:59 Terrel Pochert replied:
Thanks for your fast responses. I'm probably not explaining the issue correctly... I'm sometimes not very good at describing issues. I probably should first have said that this problem only started after updating Calendar2 to the recent version on February 8, 2012.

When trying to set the "initial date" in Calendar2 to a valid MySQL date that is already set correctly in MySQL to a very future date such as 2045-03-09, Calendar2 displays it as 1969-12-31 even though it is correct in the MySQL database. I can then set Calendar2 to something like 2050-03-09, it will update the MySQL correctly with exactly that date.

BUT when I pull that same DATE from the MySQL database using it as the initial date in Calendar2, Calendar2 displays it as 1969-12-31 instead of 2050-03-09 even though it is correct in the MySQL database.

This whole issue regarding using dates greater then 25 years into the future only started occuring after the update on February 8, 2012. I don't "think" this has anything to do with the actual MySQL database but something with using a very large "future" date as the Initial Value in the extension itself.

Reverting back to the Calendar extension before the recent update solves the problem.

Reply to this topic