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
- Calculate business days
- Java SimpleDateFormat for YYYY-MM-DDThh:mm:ssTZD
- Converting string to Date and DateTime
- Compare given date with today
- How to reformat date in PHP?
- 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?
- how to get date of yesterday using php?
- What is the MM/DD/YYYY regular expression and how do I use it in php?
- Subtracting days, months or years from date using php
- How to get time difference in minutes in PHP
- A non well formed numeric value encountered
- PHP date yesterday [duplicate]
- Adding days to $Date in PHP
- Post doesn’t show date if there’s another post with the same date
- the_date() not working
- Unable to select an old date in wordpress
- How to get date for each post?
- The purpose of the post_date_gmt?
- Why my uploaded picture was loaded into /uploads/2015/02 not /uploads/2016/01?
- How to integrate get_post_time with date_i18n function?
- Permitting WordPress to accept dates outside of 1902-2038
- How to show the real post date in a draft
- Converting Unix timestamp to wordpress date
- Keeping post_date same as the pending post_date on privately publishing the post
- Date comparison : which date format?
- Archive listing of posts by publish year (multiple years)
- Modify Date Format to German
- 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
- WordPress returns a wrong date
- Remove “at” string from wordpress comment date
- WordPress post dating – pre 1901?
- Styling the date format with date_i18n
- Unable to set right time in admin and frontend template
- WP_Query meta_query results date by date
- the_modified_date returns published date
- Page Revision date displaying on google search
- 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”
- Date and time format for UK in a custom post type [closed]
- 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
- How to get date using timezone saved in options? [duplicate]
- wordpress convert timestamp to date not correctly
- display month in french in wordpress/php?
- Show post updated date instead of published
- 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
- About Time conditionals
- After wp_insert_post(), date_i18n() and date() outputs are adjusted to GMT
- Date calculations from 2 custom fields
- Mini app that shows one unique quote each day. 56 rotating posts rotating for each themed weekday. It works, but I need your advice
- How to add a sortable date column in an admin page?
- Events are all showing the current date
- Print last modified date only on posts
- Adding number to date not working [closed]
- Set meta field to publish date + 2 weeks
- 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
- Escaping date string in url with wordpress
- Is there anything special I have to think of when setting post_date_gmt when inserting a new post?
- Format Date for Manual Insertion into post
- Wrong date returned by get_the_time
- Get_the_date doesnt show todays date [closed]
- How replace post date with event date
- Translate current_time
- Convert WordPress date format to jQuery UI Datepicker format
- Converting Y-m-d to a date with a Month name? [closed]
- Are there any know limitations on the date field, especially how old dates can be?
- 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
- How to get User Time Zone in WordPress?
- Display Author Registration Date
- Local Post Date in WordPress Admin Panel Tables
- How display modified date of most recent modified post in wordpress?
- Date Language doesn’t change
- Sort / display recent posts by publish date
- display future posts in date page
- how to show date of latest post in wordpress site?
- Month display in English but required in Swedish?
- Show different time stamp based on time
- Using php inside javascript [closed]
- Change News Story Layout Based on Date Range