Solved

All article posts and News posts are dated 30 November 1999

Posted on 2011-03-14
5
661 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

776 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