Magento2: Set product as new "from" and "to" not being interpreted correctly

Created on 18 Aug 2017  路  37Comments  路  Source: magento/magento2

Preconditions

  1. Magento 2.1.8 CE
  2. Locale set to GB

Steps to reproduce

  1. Create product
  2. Set product new from and new to dates to be 1st Aug 2017 to 1st Sep 2017

Expected result

  1. Product is listed as new in "New products Widget" if viewed during August 2017

Actual result

  1. Product is not listed as new in "New products Widget"
  2. Set product new from and new to dates to be 8th Jan 2017 to 9th Jan 2017
  3. Product is listed as new in "New products Widget" if viewed during August 2017

Looks like month and day have been interchanged.

You can also get an error when you try to set a date like 31st Aug 2017, which it says is invalid. Presumably trying to set the 8th day of the 31st month.

May be GB specific due to having date specification dd/mm/yy instead of the US mm/dd/yy

Fixed in 2.3.x Clear Description Confirmed Format is valid bug report

Most helpful comment

More insane and very serious bugs. So far Magento 2 has been such a rocky road. Endlessly need to keep patching/investigating problems in the core code.

All 37 comments

GB locale is not builtin https://github.com/magento/magento2/tree/develop/app/i18n/Magento, is there a publicly available link to the one you used?

Hi,

php bin/magento setup:static-content:deploy en_GB en_US

Under the admin pages, click arrow next to username in top right->Account Setting-Interface Locale->English (United States)

Product->Misc->Set Product New From ->Use Calendar and set 31st August 2017.
Product->Misc->Set Product New To->Use Calendar and set 30th September 2017.

Save Product OK, No error.

Under the admin pages, click arrow next to username in top right->Account Setting-Interface Locale->English (United Kingdom)

Product->Misc->Set Product New From ->Use Calendar and set 31st August 2017.
Product->Misc->Set Product New To->Use Calendar and set 30th September 2017.

Save Product -> ERROR Invalid input datetime format of value '31/08/2017'

@gwharton thanks, I was not aware en_GB was always there, just without separate translation files.

Hi @gwharton.
Thanks for reporting this issue.
Internal ticket MAGETWO-71938 was created.

also happens on fa_IR
plz fix this

I have date problems also on lt_LT. Actually I can not save correct date. The date field shows 201717-08-30 instead of 2017-08-30 after page reloads. And when I look to the database I see 1717-08-30.

Change locale to en_US fix this issue as suggested by https://github.com/magento/magento2/issues/10485#issuecomment-321543660

Duplicate of #10472 ?

This is happening with pt_BR language too.
The calendar and/or the field is not respecting locale settings?

More insane and very serious bugs. So far Magento 2 has been such a rocky road. Endlessly need to keep patching/investigating problems in the core code.

I'm having the same issue. I just updated "module-ui/Component/Form/Element/DataType/Date.php" prepare() method to set timeOffset only which seems to have fixed it. However need to do a full test to make sure it has not affected other modules that might be relying on storeTimeZone, dateFormat & storeLocale.

Update: so far didn't find an issue with the update, so if anyone interested here is the code change.
replace line 64-71 with below
if (!isset($config['timeOffset'])) { $config['timeOffset'] = (new \DateTime( 'now', new \DateTimeZone( $this->localeDate->getConfigTimezone() ) ))->getOffset(); }

@gwharton, thank you for your report.
We've created internal ticket(s) MAGETWO-71936 to track progress on the issue.

It also happens for es_ES this I am using magento 2.1.9, setup on clean, PHP version 7.0.23

@okorshenko can you assign to me?

The same problem in it-IT

the same in pl_PL

I got the same problem in vi_VN

@devhero-tech please check if https://packagist.org/packages/lcbrq/magento2-dateformatpatch would solve your problem.

thanks @Tomasz-Silpion , I made upgrade to 2.2 and works fine :)

Just so we are clear @devhero-tech and @Tomasz-Silpion, this github issue is regarding the month and date being the wrong way round for several locales. i.e when you request 30/10/2017 in the UK (and i suspect any locale where the day comes before the month), it says it is invalid, because it thinks you are trying to set the date to the 10th day of the 30th month.

The issue that the above patch is fixing is where the datetime string is being interpreted as 01/01/+00201717 etc. which is a separate issue and covered under #10485

If you have the locale set to es_ES, product import fails to due this date format issue

Same for de_DE on 2.1.9

I have installed magento 2.2.0. It continues not working after 2 years.

issue reported on Aug 18, 2017
It continues not working after 2 years.

:)

@orlangur ... 2 years or 6 months, Problems with dates and internationalization make Magento 2 almost unfeasible :(

we will probably see this fixed on 2.3 and not being backported to 2.1 and 2.2...

This is in fact a major problem when you work with clients. Enough papercut-like problems like these undermine the credibility of the whole platform.

However, there is a fix available, which works at least for 2.1.x:
https://github.com/mmularski/magento2-locale-date-time

adapted for de_DE:
https://github.com/luckyduck/magento2-locale-date-time

@luckyduck , this module have many fails. It does not correct all the bugs of all modules that magento 2.x appears. Example: Marketing Module and Reports continue not working with this module.

@sergiomendonca Agreed. Just wanted to point out that there is a solution to some of the problems. At least in my case (advanced pricing / from/to), that helped me a lot.

Thanks by the feedback. I think its the one solution until here.

I think I have the solution for this problem.
I am working in this PR and it is "in Review". Could you check it if you want?

Hi @gwharton. Thank you for your report.
The issue has been fixed in magento/magento2#11306 by @raumatbel in 2.3-develop branch
Related commit(s):

  • b237558168488b77309d69872bf2d517aa942d49

The fix will be available with the upcoming 2.3.0 release.

About all filters date? Order filter by date, invoice filter by date, customer filter by date, page filter by date. All of them is in en_us format and its not possible to make something different without change the core code of magento 2. Someone know about this issue? I downloaded the v2.2 and all the filters that i told is not fixed.

Seems to be fixed in 2.2 now

Hi @gwharton. Thank you for your report.
The issue has been fixed in #11306 by @raumatbel in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

that's not true.
I'm on 2.3.2 and the bug is still present.

still not working for bg_BG in 2.3.1

Still not working for nl_NL in 2.3.4

Can confirm still not working for ar_SA in 2.3.5-p1

Was this page helpful?
0 / 5 - 0 ratings