Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#51289 reviewing defect (bug)

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

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

Description

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 4 years ago.
Docs: Various date/time functions are returning the date/time the content was published, not written

Download all attachments as: .zip

Change History (13)

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


4 years ago

@audrasjb
4 years ago

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

#2 @audrasjb
4 years 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
4 years ago

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

#4 @SergeyBiryukov
4 years 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
4 years 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 4 years ago by Rarst (previous) (diff)

#6 @helen
4 years 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.


4 years ago

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


3 years ago

#9 @desrosj
3 years 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.


3 years ago

#11 @desrosj
3 years 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.

#12 @azouamauriac
2 years ago

I think this bug is deeper and more over a word issue. Since WordPress assumes that 'publish date' = 'write date' and save both data in 'post_modified' attribute. I don't think that way to see things is really right. A post can write without published; so both dates should be handled by different properties.

Version 0, edited 2 years ago by azouamauriac (next)
Note: See TracTickets for help on using tickets.