Solved

All article posts and News posts are dated 30 November 1999

Posted on 2011-03-14
5
665 Views
Last Modified: 2012-05-11
Hi hope someone can help, this is driving me crazy.

For some reason one of our Joomla installations is not displaying the correct date for articles and News items. The server time settings are correct, and our other sites on the same server do not have this problems

The date shows correctly when the article is added  but when its goes live or is saved the time defaults to November 30 1999.

Correct date shown when creating article Incorrect date shown on posted article Incorrect time shown in Joomla admin
0
Comment
Question by:yorkshireladdie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 125 total points
ID: 35129316
I've seen this sort of thing happen before in ZenCart where a date was supposed to be in d/m/y format but was being converted as if it was in m/d/y format and I suspect that is what is happening here. The software performing the retrieval is putting the date into the wrong format and that wrong format is then saved overwriting the correct format.

0
 

Author Comment

by:yorkshireladdie
ID: 35129443
That's a thought - although I can't find anywhere in the settings to amend the date format, I don't think we've ever opted to amend it to anything other than the standard display. Thanks for your reply though, I'll take another look to see if there are any options.



0
 
LVL 14

Expert Comment

by:Scott Madeira
ID: 35131221
The date is showing as 11/30/1999 because the date that is actually stored in the database is 00-00-0000.  When rendered through the PHP script it is showing it as 11/30/1999.  

You need to figure out what is wrong with the date information that is being fed into the database that is causing it to not save the date field and instead defaulting to 00-00-0000.

You could step through the site using xDebug or some other debugging tool to follow the data as it goes to the database (to verify it is being saved correctly) and then coming back out of the database.

If you don't have xDebug then some well placed echo statements could do the same thing for you.  The first step is to see where the data is getting messed up.
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35136331
The place to start is the code that takes the date from the screen and stores it in the database. If there is anything wrong with the date then MySQL has a habit of storing it as 0000-00-00. So what could be going wrong? Here is a list of the usual suspects...

1. The date is being inserted in the query as (say) '03/15/2011' or '2011/03/15'. Neither will do. Dates must ALWAYS be presented to MySQL formatted as 2011-03-11

2. The variable being used to store the date has blanks or zeros in it, not the date.

3. The variable being used to store the date is misspelled. Remember that PHP is case sensitive so $a and $A are different variables.

FInd the SQL statement that does the add and stick an echo and an exit after it then run the routine and look at the query text. So if you have something like

mysql_query("INSERT INTO myTable ( theDate ) VALUES ('$theDate' ) ");

Open in new window


then copy this and change mysql_query to echo like so

mysql_query("INSERT INTO myTable ( theDate ) VALUES ('$theDate' ) ");
echo ("INSERT INTO myTable ( theDate ) VALUES ('$theDate' ) ");
exit;

Open in new window


 try that and see what pops out
0
 

Author Closing Comment

by:yorkshireladdie
ID: 35136570
Thanks - bportlock.

This one combined with other online research put me on the right track.

I found the relevant language file (language >>en-GB) and removed the hours and minutes from the DATE_FORMAT_LC settings and that did the trick :)

Thanks to everyone for their suggested answers.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question