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:
<?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:
To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().
From this point of view, I think it would be best to use strftime as much as possible, if you even have a remote possibility of having to localize your application. If that’s not an issue, pick the one you like best.
Related Posts:
- Convert number to month name in PHP
- Compare given date with today
- R Programming Error in cov.wt(z) : ‘x’ must contain finite values only
- How to find the date of a day of the week from a date using PHP?
- Convert a date format in PHP
- Convert a Unix timestamp to time in JavaScript
- How to find the last day of the month from date?
- What is the MM/DD/YYYY regular expression and how do I use it in php?
- How to get time difference in minutes in PHP
- A non well formed numeric value encountered
- PHP date yesterday [duplicate]
- How to get date for each post?
- Permitting WordPress to accept dates outside of 1902-2038
- Keeping post_date same as the pending post_date on privately publishing the post
- Date comparison : which date format?
- XML export posts from one single day
- Bulk edit post date in wordpress
- Serve visitor post time adjusted to their timezone
- Automatically move pending posts after 30 days and, update the post date, when users update the posts
- month name translation
- Count days from registration date to today
- Remove “at” string from wordpress comment date
- Unable to set right time in admin and frontend template
- WP_Query meta_query results date by date
- Change date from 2015/02/23 to “1 min ago”
- Display page only if user registered before a specific date
- Way to display “Yesterday”, “Today”
- Display post date as 04/26/2013
- What are the “U” and “G” time formats?
- date() returns incorrect value if used from WordPress theme, but correct otherwise
- display month in french in wordpress/php?
- Set the publication date independent of the scheduled publication date
- Get date numerical and separate?
- Add a link to display posts with a specific tag within a date range
- After wp_insert_post(), date_i18n() and date() outputs are adjusted to GMT
- How to add a sortable date column in an admin page?
- Print last modified date only on posts
- Only showing the_date and the_excerpt for first entry in get_posts
- How to manually change current date to post date in frontend?
- Do multiple jobs on date change without WordPress cron job
- Wrong date returned by get_the_time
- How replace post date with event date
- Translate current_time
- Converting Y-m-d to a date with a Month name? [closed]
- Conditional: IF post creation date is in the first half OR last half of the year [closed]
- Display published time for today’s posts only
- Return date in French
- convert time to WordPress user’s local time
- How would I use this filter to change the output of the date format to “Twitter time”?
- Change post date for testing purposes
- Local Post Date in WordPress Admin Panel Tables
- Sort / display recent posts by publish date
- Month display in English but required in Swedish?
- Change News Story Layout Based on Date Range
- Update post date of page when Visitor access that page?
- date format of custom date variable
- Check if is Post or Comment
- Create a date archives template page for custom post type
- changing type of date picker in contact form 7 date picker plugin
- If X Amount of Time Has Passed Since Post Was Published, Do Something
- Issue in displaying the ongoing event and current events in the post
- Not work hide comments with future date
- Translate Post date (month) of china language
- I want to format my Post dates differently to other dates on my website
- Don’t update modified post date when user add a product review or comment?
- How to display posts categori list by day wordpres
- Possible to edit custom date field and display?
- Get posts from year from URL
- Update existing post times to random times?
- Primary navigation menu with timed items from custom post type
- Tumblr imported blog showing wrong date
- Can’t add to time? [closed]
- Timezone for Plugin
- Grouping posts by date
- How to hide post published date?
- WordPress change post date format from english to japanese
- How to display Date and Time in Tamil Language?
- Adding a number to a date
- Get current week’s day and time outside the loop
- Display Year and Month from custom field + Age Calculator
- Issue with strtotime() and Meta Box date
- suffix title with “EXPIRED” when scheduled post has reached it’s published date
- Use the_date with link
- Get month and day from a Date Picker custom field
- Show post date on the page
- automatic send email at custom time
- Change the date and time in wordpress
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- Post publish date [duplicate]
- Set Custom Date for Posts
- Posted date format not reflected
- check if a draft has been moved there from publish to draft
- Make datestamp for status updates show time
- Saving Revision of post meta key/value on each update_post_meta event
- Get system timestamp in wordpress
- Limit access to a page
- In my Website homepage I want to remove date which is written along author name [closed]
- get_the_date() return always UTC+0 [duplicate]
- Docker Container time & timezone (will not reflect changes)
- How to customize Date Format for American visitors?