How do I use PHP to get the current year?

后端 未结 26 2228
萌比男神i
萌比男神i 2020-12-04 04:31

I want to put a copyright notice in the footer of a web site, but I think it\'s incredibly tacky for the year to be outdated.

How would I make the year update automat

相关标签:
26条回答
  • 2020-12-04 05:21

    My way to show the copyright, That keeps on updating automatically

    <p class="text-muted credit">Copyright &copy;
        <?php
            $copyYear = 2017; // Set your website start date
            $curYear = date('Y'); // Keeps the second year updated
            echo $copyYear . (($copyYear != $curYear) ? '-' . $curYear : '');
        ?> 
    </p>    
    

    It will output the results as

    copyright @ 2017   //if $copyYear is 2017 
    copyright @ 2017-201x    //if $copyYear is not equal to Current Year.
    
    0 讨论(0)
  • 2020-12-04 05:23
    <?php date_default_timezone_set("Asia/Kolkata");?><?=date("Y");?>
    

    You can use this in footer sections to get dynamic copyright year

    0 讨论(0)
提交回复
热议问题