Question

I am looking for an equivalent PHP function to accomplish what document.write(new Date().getFullYear() is expected to do. This function is to be used in place of deprecated document.write(new Date().getFullYear()) in the footer section that you see in Magento Admin where HTML code can be placed for the footer text. Any advice or help greatly appreciated.Below is what I thought should have worked out.

<div class="page-container footer-toolbar footer-toolbar-bottom"><div class="content"><small class="copyright">
<span><center>COPYRIGHT © 2013-<?= date("Y"); ?> mymagentosite.COM. ALL RIGHTS RESERVED.</center></span>
</small>

enter image description here

Was it helpful?

Solution

Get full Year used:

<?= date('Y'); // it will display full year ex. 2017 ?>

Or get only two digit of year used like this:

<?= date('y'); // it will display short 2 digit year ex. 17 ?>

or

<?php echo date("d-m-Y") ?>

explanation:

d = day
m = month
Y = year

use a PHP function which is just called date().

It takes the current date and then you provide a format to it

and the format is just going to be Y. Capital Y is going to be a four-digit year.

My super lazy version of showing a copyright line, that automatically stays updated:

&copy; <?php 
$copyYear = 2008; 
$curYear = date('Y'); 
echo $copyYear . (($copyYear != $curYear) ? '-' . $curYear : '');
?> Me, Inc.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top