Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update product.php #2225

Closed
wants to merge 1 commit into from
Closed

Update product.php #2225

wants to merge 1 commit into from

Conversation

CoverUp
Copy link
Contributor

@CoverUp CoverUp commented Nov 7, 2014

I have noted that sometimes recently added products are not displayed at all, so you start to figure out whats wrong... you check the database and the new item is there, everythings look good but your new added products just don't appear in your category or categories. well after a looooong checking i found the cause:
MySQL date could be different from your php date, so when you add a product with the current date, the product is saved with that date in the field date_available.
But then, when you reload the page to see your new added product in your site, the system use the mysql date instead the php date, and if the mysql date is several hours behind the php date the product don't appear because the operation p.date_available <= NOW() is not meet.

Sadly most of the webhosts offer only a cpanel without shell, so you can't configure mysql timezone in order to match php timezone

Thus, in order to avoid this particular issue i propose to change NOW() to date(), the result is the same but also solve this issue.

You can replicate the issue as follow:

mysql timezone set with default +0:00
php timezone set with +2:00
php time is the same as your PC time
thus
your pc date/time: 2014-07-11 01:00 am
php date/time: 2014-07-11 01:00 am
mysql date/time: 2014-07-10 23:00 pm

at 1:01 yo add a new product as always
at 1:10 you try to see the new product but is not displayed
cause: 2014-07-10 from NOW() is compared with 2014-07-11 saved from date()

please note that this issue only appear if you add products after midnight, it's like a bad nightmare 👻

The solution:
changed NOW() (with current date/time from mysql) to date('Y-m-d') (with current date from php) to solve issues found when timezone on mysql are not equal to timezone on php

pd: only yyyy-mm-dd is saved on the DB during product add, that's why we use date(Y-m-d) as a replacement of NOW()

changed NOW() (with current date/time from mysql) to date('Y-m-d') (with current date from php) to soleve issues found when timezone on mysql are not equal to timezone on php
@danielkerr
Copy link
Member

sorry not doing this! host should make sure the dates are correct

@danielkerr danielkerr closed this Nov 7, 2014
@CoverUp
Copy link
Contributor Author

CoverUp commented Nov 7, 2014

well, it's ok, at least it will be here for future reference, perhaps a warning during install will also help. strange issues are a real pain.

@CoverUp CoverUp mentioned this pull request Jan 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants