I created a really simple block in my child theme:
/Magento_Theme/layout/default.xml:
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="custom_time_block" template="Magento_Theme::html/custom-time-block.phtml" before="-"/>
</referenceContainer>
/Magento_Theme/templates/html/custom-time-block.phtml:
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<?php
$now = new DateTime();
echo $now->format('H:i:s');
?>
</div>
</div>
</div>
So when I clear the cache, the time that is displayed, is the time when I cleared the cache. The time is not the current time. So how can I get this working without:
- cacheable="false" (because this block is going to be dislayed everywhere, so each page will not be cached)
- Javascript: I want to display the server time, not the client time
Thank you in advance!