Open stsharp opened 5 years ago
@stsharp I tried to fix start time and end time as your code provided. But It doesn't work for me. Any ideas? or I did miss something ?
For example: Now America/Chicago time is 3/23 1:15 AM I tried to edit start time of banner. After save that, the time become to 3/22 8:15 PM. The banner grid of admin panel is not display correctly. But the banner applying time is correct. If the time pass to 3/23 1:15 AM, the banner will be display to frontend. Any one know how to fix this issue?
I found if install this module to Magento 2.2, there is no issue about save start_time and end_time problem. But install into Magento 2.3, will be caused this issue happen.
It seems if we try to adjust the start and end time to an exact minute, it is not saved that way. It seems that the following code will help fix this:
File: Controller/Adminhtml/Banner/Save.php Line 107 Change from $data['start_time'] = $localeDate->date($data['start_time'])->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i'); TO $data['start_time'] = $localeDate->date(new \DateTime($data['start_time']))->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i');
Line 108 Change from $data['end_time'] = $localeDate->date($data['end_time'])->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i'); To $data['end_time'] = $localeDate->date(new \DateTime($data['end_time']))->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i');