Post by Joe1234 » Thu Aug 18, 2022 2:52 pm

I'm converting all of my dates from Y-m-d to m-d-Y with an extension (for the life of me I don't understand why this isn't a baked in option). The problem I'm running into is the product form is messing up my date available and added input (extension). When I save the form it saves all zeros to the database and then populates the form as some weird date like 11-30--0001 or 01-01-1970 which doesn't make any sense to me. I've tried adding the following codes right before the update database on the model product page but it doesn't work...gives me the same populated gibberish.

Code: Select all

$data['date_added'] = date('Y-m-d');
I tried this with the parameters reversed

Code: Select all

$data['date_added'] = date("Y-m-d", strtotime(str_replace("-","/",$data['date_added'])));
I tried this with the parameters reversed

Code: Select all

  $data['date_added'] = date("Y-m-d", strtotime($data['date_added']));  
I tried putting a msg box or print_r() within that function that is updating the database so I could see what is going on, but they don't seem to work within that function so I'm stuck.
Can someone show me why this isn't working?
Last edited by Joe1234 on Fri Aug 19, 2022 6:14 am, edited 1 time in total.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by paulfeakins » Thu Aug 18, 2022 4:53 pm

Joe1234 wrote:
Thu Aug 18, 2022 2:52 pm
I'm converting all of my dates from Y-m-d to m-d-Y with an extension (for the life of me I don't understand why this isn't a baked in option).
What dates where? And what extension?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by ADD Creative » Thu Aug 18, 2022 5:04 pm

What SQL query are you using to write to the database?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by thekrotek » Thu Aug 18, 2022 5:32 pm

It's not a weird date, it's a badly formatted date. Formatting has some limitations and rules like using a particular separator (dash, slash or dot) for certain cases. So when you try to format a wrong date it returns you the "zero date" which is 01.01.1970

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by Joe1234 » Fri Aug 19, 2022 6:13 am

This ended up working:

Code: Select all

$data['date_added'] = date("Y-m-d", strtotime(str_replace("-","/",$data['date_added'])));
The primary problem was an extra "$" on the variable on the sql insert that I wasn't seeing.
It turned out to be a good thing this happened because all the hunting I did to find this I saw a bunch of holes and improvements that needed to be done to the extension so it worked out in the end.

Thanks.

v3.0.3.9 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: No registered users and 260 guests