Make WordPress Core

Opened 12 months ago

Last modified 3 months ago

#51289 reviewing defect (bug)

Documentation issue: get_post_time is getting the time when published not when created

Reported by: casiepa Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-patch good-first-bug needs-refresh
Focuses: docs Cc:


I'm having a doubt with https://developer.wordpress.org/reference/functions/get_post_time/ (probably the same with https://developer.wordpress.org/reference/functions/get_the_date/)
They both say 'Retrieve the date on which the post was written.', but from some programming I'm doing now it looks more like 'Retrieve the date on which the post was PUBLISHED.'.

Test: create a post in draft or pending and check that date using the function. (I'm doing it with a CPT)

Attachments (1)

51289.diff (6.5 KB) - added by audrasjb 12 months ago.
Docs: Various date/time functions are returning the date/time the content was published, not written

Download all attachments as: .zip

Change History (12)

This ticket was mentioned in Slack in #docs by casiepa. View the logs.

12 months ago

12 months ago

Docs: Various date/time functions are returning the date/time the content was published, not written

#2 @audrasjb
12 months ago

  • Component changed from General to Date/Time
  • Keywords has-patch added

Thanks for raising this issue Pascal!

I updated the following functions/hooks:

  • the_date_xml
  • the_date
  • get_the_date
  • get_the_modified_date
  • the_time
  • get_the_time
  • get_post_time
  • get_post_modified_time
  • the_weekday
  • the_weekday_date

#3 @SergeyBiryukov
12 months ago

  • Milestone changed from Awaiting Review to 5.6
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @SergeyBiryukov
12 months ago

This might need some further clarification, as it's not quite clear what "published" means for a draft or pending post.

In my testing:

  • For a draft post that never was published, get_the_date() returns the date of the last edit.
  • For a post that was previously published, get_the_date() returns the published date.

For both of these cases, the existing docs seem accurate. 51289.diff would only be accurate for the second case.

#5 @Rarst
12 months ago

The current wording is imperfect, but "was published" would imply a post is published. It might be not published. It might be scheduled for the future.

I think it should be neutral wording like "the date of the current post", which is already partially there. It just describes the return without implications about state of the post.

Last edited 12 months ago by Rarst (previous) (diff)

#6 @helen
11 months ago

  • Keywords good-first-bug needs-refresh added
  • Milestone changed from 5.6 to 5.7

I agree this can be worded as "the date of the post" for most of these, a few seem a little tricker (e.g. "The weekday name of the date of the post"?) but I'm confidence somebody with some wordsmithing skills can figure it out :) Punting out of 5.6 for now, strongly encourage some contributions here.

This ticket was mentioned in Slack in #core by helen. View the logs.

11 months ago

This ticket was mentioned in Slack in #core by sergey. View the logs.

8 months ago

#9 @desrosj
7 months ago

  • Milestone changed from 5.7 to 5.8

This one hasn't seen any activity in this release cycle and still needs a patch refresh to address feedback. I'm going to punt, but if a committer has time to review, it can be moved back.

This ticket was mentioned in Slack in #core by chaion07. View the logs.

4 months ago

#11 @desrosj
3 months ago

  • Milestone changed from 5.8 to Future Release

Since this has not seen any activity during the 5.8 release cycle, I'm punting to Future Release. When a contributor is able to create a new patch, it can be moved back to a numbered milestone.

Note: See TracTickets for help on using tickets.