Magento 2
Create a Class Preference
Free Preview
// Since we are overriding the "Review" module, let's name our module "Review".
namespace Foo\Review\Block;

// We also want to name our class the same as the class we are overriding.
class View extends \Magento\Review\Block\View
    // Only define the functions you wish to modify, as every other function
    // call falls back to the parent class.

     * Format date in medium format (core returns long format).
     * @param string $date
     * @return string
    public function dateFormat($date)
        return $this->formatDate($date, \IntlDateFormatter::MEDIUM);
<?xml version="1.0"?>
<!-- Place this file in either the "frontend" or "adminhtml" folder -->
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!-- The "preference" node tells Magento which class to load -->
    <!-- "for" = the class you wish to override -->
    <!-- "type" = your customized class -->
    <preference for="Magento\Review\Block\View" type="Foo\Review\Block\View" />
<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Foo_Review">
            <!-- Add the module we are overriding to the sequence node. -->
            <!-- This ensures our module loads after and takes precedence. -->
            <module name="Magento_Review"/>
Want to learn more?

Visit to learn much more about Magento, Laravel, PHP, Javascript, & Docker. logo