Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Show post updated date instead of published

get_the_modified_date should do what you’re looking for. I am guessing that perhaps you are struggling a bit with the sprintf syntax.

 $date = sprintf( '<span>' . __( 'Posted', 'theme' ) . ' <a href="%3$s"><time class="entry-date" datetime="%1$s">%2$s</time></a></span>',
    esc_attr( get_the_date( 'c' ) ),
    esc_html( time_ago() ),
    esc_html( get_day_link( get_the_date('Y'), get_the_date('m'), get_the_date('d') ) )
  );

Let’s break it down:

sprintf argument 1 – the string with placeholders

sprintf( '<span>' . __( 'Posted', 'theme' ) . ' <a href="%3$s"><time class="entry-date" datetime="%1$s">%2$s</time></a></span>',

This is the main string that will be built. It has 3 placeholders. However, they are in a non-traditional order.

  1. The link (<a href=%3$s) has a placeholder for variable #3, a string.
  2. The datetime attribute (datetime=%1$s), which is part of the HTML time element that makes the time machine-readable (useful for advanced features, and if the time element contains more than just the actual time), has a placeholder for variable #1, a string.
  3. And finally the displayed time (>%2$s</time>) is looking for variable #2, a string.

sprintf arguments 2,3, and 4 – the values

Those 3 variables are provided in the following function arguments (again, not in the order they are used):

esc_attr( get_the_date( 'c' ) ),
esc_html( time_ago() ),
esc_html( get_day_link( get_the_date('Y'), get_the_date('m'), get_the_date('d') ) )

The first, which is feeding into that datetime= attribute, is getting the post’s published date and outputting it in the ‘c’ format, which is a standard date format that looks like 20019-03-27T15:19:21+00:00.

The second, which is the displayed time, is referencing a function I don’t recognized, called time_ago().

The third, which is being used for the link href=, is generating the link based off of the post’s published date.

So, to properly change the date and still use that function, we should adjust all 3 parameters.

$date = sprintf( '<span>' . __( 'Posted', 'theme' ) . ' <a href="%3$s"><time class="entry-date" datetime="%1$s">%2$s</time></a></span>',
    esc_attr( get_the_modified_date( 'c' ) ),
    esc_html( get_the_modified_date(),
    esc_url( get_day_link( get_the_modified_date('Y'), get_the_modified_date('m'), get_the_modified_date('d') ) )
  );

Note I changed the 3rd parameter to esc_url since it is a URL that is being generated, and that the display of the output date can be adjusted by passing in PHP date formatting options, such as get_the_modified_date( ‘m-d-Y’ )

Finally, all of this is getting stored in your $date variable as HTML, so make sure to actually echo it to the page before you’re done.

Related Posts:

  1. Saving Revision of post meta key/value on each update_post_meta event
  2. Java SimpleDateFormat for YYYY-MM-DDThh:mm:ssTZD
  3. How do I use PHP to get the current year?
  4. R Programming Error in cov.wt(z) : ‘x’ must contain finite values only
  5. Convert a Unix timestamp to time in JavaScript
  6. Convert number to month name in PHP
  7. Post doesn’t show date if there’s another post with the same date
  8. Unable to select an old date in wordpress
  9. How to get date for each post?
  10. The purpose of the post_date_gmt?
  11. Why my uploaded picture was loaded into /uploads/2015/02 not /uploads/2016/01?
  12. How to integrate get_post_time with date_i18n function?
  13. Permitting WordPress to accept dates outside of 1902-2038
  14. How to show the real post date in a draft
  15. Converting Unix timestamp to wordpress date
  16. Keeping post_date same as the pending post_date on privately publishing the post
  17. Permalinks using event date (year & month) instead of publication date
  18. Date comparison : which date format?
  19. Modify Date Format to German
  20. XML export posts from one single day
  21. Bulk edit post date in wordpress
  22. Ordering posts by anniversary using only day and month
  23. Serve visitor post time adjusted to their timezone
  24. Automatically move pending posts after 30 days and, update the post date, when users update the posts
  25. month name translation
  26. Count days from registration date to today
  27. Human Time Diff, change mins to minutes
  28. Get posts by meta value with date
  29. Displaying posts with only upcoming dates according their custom field date value
  30. Remove “at” string from wordpress comment date
  31. WordPress post dating – pre 1901?
  32. Styling the date format with date_i18n
  33. the_modified_date returns published date
  34. Displaying custom posts only if custom meta box’s date is not expired
  35. Page Revision date displaying on google search
  36. Change date from 2015/02/23 to “1 min ago”
  37. Display page only if user registered before a specific date
  38. Date and time format for UK in a custom post type [closed]
  39. Display post date as 04/26/2013
  40. What are the “U” and “G” time formats?
  41. date() returns incorrect value if used from WordPress theme, but correct otherwise
  42. How to get date using timezone saved in options? [duplicate]
  43. wordpress convert timestamp to date not correctly
  44. Set the publication date independent of the scheduled publication date
  45. Header: Include Date Published and Date Modified
  46. Add a link to display posts with a specific tag within a date range
  47. About Time conditionals
  48. After wp_insert_post(), date_i18n() and date() outputs are adjusted to GMT
  49. Mini app that shows one unique quote each day. 56 rotating posts rotating for each themed weekday. It works, but I need your advice
  50. How to add a sortable date column in an admin page?
  51. Events are all showing the current date
  52. Do multiple jobs on date change without WordPress cron job
  53. Escaping date string in url with wordpress
  54. Is there anything special I have to think of when setting post_date_gmt when inserting a new post?
  55. Format Date for Manual Insertion into post
  56. Wrong date returned by get_the_time
  57. Get_the_date doesnt show todays date [closed]
  58. Ordering posts by custom field named “date” in backend
  59. How replace post date with event date
  60. Translate current_time
  61. Are there any know limitations on the date field, especially how old dates can be?
  62. Conditional: IF post creation date is in the first half OR last half of the year [closed]
  63. Display published time for today’s posts only
  64. Return date in French
  65. convert time to WordPress user’s local time
  66. How to remove Date from Meta Description on SERP?
  67. Sort Posts By Custom Field Date?
  68. Change post date for testing purposes
  69. Display Author Registration Date
  70. Local Post Date in WordPress Admin Panel Tables
  71. How display modified date of most recent modified post in wordpress?
  72. Date Language doesn’t change
  73. Sort / display recent posts by publish date
  74. display future posts in date page
  75. how to show date of latest post in wordpress site?
  76. Month display in English but required in Swedish?
  77. Show different time stamp based on time
  78. Change News Story Layout Based on Date Range
  79. Update post date of page when Visitor access that page?
  80. Switch Categories on a Specific Date?
  81. Randomizing Post Links Outside of Loop – No Author or Date
  82. Media attachment date and post date
  83. Group Posts By Custom Meta Value: Date
  84. date format of custom date variable
  85. Is it possible to change X Hours Ago to date in WP Admin?
  86. Display Current Date using shortcode
  87. Check if is Post or Comment
  88. Create a date archives template page for custom post type
  89. changing type of date picker in contact form 7 date picker plugin
  90. If X Amount of Time Has Passed Since Post Was Published, Do Something
  91. Get current user last post date
  92. Not work hide comments with future date
  93. Translate Post date (month) of china language
  94. I want to format my Post dates differently to other dates on my website
  95. How to display posts categori list by day wordpres
  96. Can’t convert ACF datepicker value to DateTime oject – gives me a boolean
  97. Count time from registration date to today
  98. How to add published date in product [closed]
  99. Update existing post times to random times?
  100. Update post meta date always store 1970-01-07
Categories date Tags date, post-meta
Landing Page Redirect Chain | http->https->https www
Add keywords meta to index.php page

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress