Magento is a ready to use e-commerce platform built on open source technology PHP which has all major in-built functionality for online store such as product catalog, cart, coupon, cms pages, user registration and login and payment gateway etc. Magento is one of the most favorite e-commerce platform on internet.
No doubts it’s best platform but some time you get annoying error which just come you don’t have any idea how it’s came , what i did wrong?
A same type of experience i also get during working on it, may be you also get the same error that’s why you are here ๐
I get “invalid date format error” while adding or editing products.(I am using Magento 2.3.4)
See the below image of error what i get –
Let’s see how we can resolve it –
- First you have to directory/folder/file access permission.
- Go to “magento” root folder .
- Go to “vendor/magento/framework/Stdlib/DateTime/Timezone.php“.
- Find the “appendTimeIfNeeded” method –
private function appendTimeIfNeeded($date, $includeTime) { if ($includeTime && !preg_match('/\d{1}:\d{2}/', $date)) { $date .= " 0:00am"; } return $date; }
- Under “appendTimeIfNeeded” method you can see there is a “$date” variable having value “0:00am“.
- Just replace the “$date” value with “0:00“.
- See below is the update code –
private function appendTimeIfNeeded($date, $includeTime) { if ($includeTime && !preg_match('/\d{1}:\d{2}/', $date)) { $date .= " 0:00"; } return $date; }
Note : Please take a backup of this file before replacing and updating.
Hope this solution solved your problem.