0

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

1
  • try this <?php echo date('d/m/yy');?> Commented May 7, 2020 at 17:18

1 Answer 1

0

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.
5
  • you are right, but this is not taking effect when placed your code in the admin panel in the section for the footer. Please refer the screenschot. Commented May 7, 2020 at 17:45
  • try to create a copyright template then call to block and then set widget after the footer
    – Devidas
    Commented May 7, 2020 at 17:54
  • Could you please share a link to creating a copyright template as you suggested? I think my method doesn't work. Commented May 7, 2020 at 17:58
  • no, any link I suggest you create custom copyright template in your theme then this template call to admin block and then create one widget for select this block and load to set after the footer. I hope you understand what I mean
    – Devidas
    Commented May 7, 2020 at 18:10
  • Fixed this with the help of custom copyright template as advised. Commented May 7, 2020 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.