Jump to content

[Solved] New order shows Invalid date on backend


Recommended Posts

When any order is submitted through our system we are not able to manage it via the backend system. Clicking on "Orders" gives us a list of all the orders, but then trying to view the detail of the order all we see is the ability to change the status and the message "Invalid date". This seemed to work fine on a previous version of PHP / server but after upgrading servers we can no longer view the orders. I've scoured Google for anyone with the same issue and was unable to come up with ANYTHING relevant.

I've attached a screenshot of what it is exactly we're seeing. And here is some information about our configuration.

PrestaShop Version 1.3.0.9
PHP Version 5.3.3
Apache Version 2.2.16
MySQL Version 5.0.45
Cent OS Linux 5.5 x64

The dates it's showing on the order are the correct date & time and I've even confirmed this by going into the ps_order_history table in the database and finding the record, the date_add column is also showing the correct date / time so I really don't see why it's flipping out about this date as I don't see anything wrong with it which leads me to believe that something in the code isn't formatting / reading the date fields properly in PHP. We've made some pretty drastic changes though to our configuration so I can't guarantee it's the PHP version that's causing this as we've upgraded the version of Apache, new version of PHP, switched from x32 to x64 servers, upgraded the version of Cent OS... None of these are things I can go back on as we required these new versions for our other projects we manage.

Looking through the code base I've found where the error is actually getting triggered but it's something I'd rather not have to tweak as that leaves to a harder upgrade process later.

classes -> Tools.php -> Line 280 starts with this method that throws an error if the Validate fails
static public function displayDate($date, $id_lang, $full = false, $separator='-')
{
if (!$date OR !strtotime($date))
return $date;
if (!Validate::isDate($date) OR !Validate::isBool($full))
die (self::displayError('Invalid date'));
$tmpTab = explode($separator, substr($date, 0, 10));
$hour = ' '.substr($date, -8);

$language = Language::getLanguage(intval($id_lang));
if ($language AND strtolower($language['iso_code']) == 'fr')
return ($tmpTab[2].'-'.$tmpTab[1].'-'.$tmpTab[0].($full ? $hour : ''));
else
return ($tmpTab[0].'-'.$tmpTab[1].'-'.$tmpTab[2].($full ? $hour : ''));
}

If anyone has ANY ideas I'd be more then happy to try them as I've seriously run out...Thanks in advance.

29273_eXix7cYEebbIjMLCTzYh_t

Link to comment
Share on other sites

I figured it out, we had imported our accounts from another system into PrestaShop. The date_add field within the ps_customer table is currently set to datetime and we didn't set a value on this field on our import. The order form actually shows when the customer signs up so it was failing on that part but never display any help on what date / where it was coming from that was failing.

In my personal opinion the date_add field should have a type of timestamp rather then datetime, this would ensure that the field has a value in any scenario if it's going to be relied on like that...

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

I had the same problem and this post was the fix. Here is a SQL query I ran to replace the invalid date vales:

update `ps_customer`
SET date_add = REPLACE(date_add, '0000-00-00 00:00:00', '2010-12-15 12:00:00')



Everything worked fine after this. Another symptom before the dates were fixed was the PDF module created documents that returned errors when trying to open with Adobe reader.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

I'm having this same issue and need to consistently upload new customers on a daily basis. I'm using the backoffice tool- import option. If I make this SQL change does it need to be done after or before every import? I don't usuall use SQL...

The faster the better if you have a chance to answer this! Thank you

 

Nevermind, used your code & works like a charm.

update `ps_customer`

SET date_add = REPLACE(date_add, '0000-00-00 00:00:00', '2010-12-15 12:00:00')

Edited by Adria (see edit history)
Link to comment
Share on other sites

  • 4 months later...

Hello there,

I'm having the same problem and I take a look at my ps_customer table and the date is OK. The fact in that in my backend when I try to see the orders some of them show the error above "INVALID DATE"

If i use this sql request that would just change 0000-00-00 00:00:00 to 2010-12-15 12:00:00 everywhere in the ps_customer. I guess I should apply that sql request to ps_order table where in fact I can some 0000-00-00 00:00:00, but I don't want to put the same date everywhere. Any help? :-(

Link to comment
Share on other sites

  • 4 months later...

Hello, i just got this problem, and i have own solution for this.

 

1. First of all, check your database at ps_orders (table)

2. Search your order that have a problem with "invalid date", you can search using tab search in phpMyadmin reference to your id order.

2. Then check at invoice_date field. It must be empty, that is the problem, the invoice_date cannot be empty.

3. Edit your invoice_date, fill the date same as date_add field,

4. Save

 

then refresh your order link at the back end.

 

done!

Link to comment
Share on other sites

Hello, i just got this problem, and i have own solution for this.

 

1. First of all, check your database at ps_orders (table)

2. Search your order that have a problem with "invalid date", you can search using tab search in phpMyadmin reference to your id order.

2. Then check at invoice_date field. It must be empty, that is the problem, the invoice_date cannot be empty.

3. Edit your invoice_date, fill the date same as date_add field,

4. Save

 

then refresh your order link at the back end.

 

done!

 

but this problem will occur in the future too, right? so after each order i will have to edit the database manually?

Link to comment
Share on other sites

  • 7 months later...

Hi at all,

i have the same problem in my 1.4.7.3 version. I dont understand where can make this change:

update `ps_customer`SET date_add = REPLACE(date_add, '0000-00-00 00:00:00', '2010-12-15 12:00:00')

 

I Actually go to my sql database and manually change the date, but is not a valid solution,

the date must be change automatically from prestashop.

 

thanks for your help,

Simone

Link to comment
Share on other sites

×
×
  • Create New...