Magento 2
Create a class preference
Free Preview
app/code/Acme/Review/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Acme_Review">
        <sequence>
            <!--
            Add the module being overridden to the sequence node, which defines
            it as a dependency. This ensures the other module loads first,
            making your module load after and take precedence.
            -->
            <module name="Magento_Review"/>
        </sequence>
    </module>
</config>
app/code/Acme/Review/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!--
    This file is located in either the "frontend" or "adminhtml" folder,
    depending upon which area you wish too target.
    
    The "preference" node tells Magento which class to load. When the "for" class
    is requested, Magento will swap this class out for the "type" during the
    compilation process.
    -->
    <preference for="Magento\Review\Block\View" type="Acme\Review\Block\View"/>
</config>
app/code/Acme/Review/Block/View.php
<?php declare(strict_types=1);

// You can name your module the same as the one being overridden. The different
// vendor name is enough to differentiate itself.
namespace Acme\Review\Block;

// This class should have the same name as the one you are overriding. Since your
// class extends the original class, it only needs to contain the functions you
// wish to override. Don't copy over other methods that aren't being modified.
class View extends \Magento\Review\Block\View
{
    // There is no need to copy over docblocks as they are auto-inherited.
    // You may, however, wish to document the changes made to this function.

    /**
     * Format date in medium format instead of long format.
     */
    public function dateFormat($date)
    {
        return $this->formatDate($date, \IntlDateFormatter::MEDIUM);
    }
}
Want to learn more?

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

M.academy logo