Solved

All article posts and News posts are dated 30 November 1999

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now