You can use either date or strftime. In this case I’d say it doesn’t matter as a year is a year, no matter what (unless there’s a locale that formats the year differently?)

For example Current Year in PHP:

<?php echo date("Y"); ?>

On a side note, when formatting dates in PHP it matters when you want to format your date in a different locale than your default. If so, you have to use setlocale and strftime. According to the php manual on date:

Note:

To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().

For WordPress Copyright Year Shortcode:

function year_shortcode() {
  $year = date('Y');
  return $year;
}
add_shortcode('year', 'year_shortcode');

About The Author

Related Posts

Leave a Reply

Your email address will not be published.