#51289 closed defect (bug) (fixed)
Documentation issue: get_post_time is getting the time when published not when created
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | has-patch changes-requested |
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)
Change History (20)
This ticket was mentioned in Slack in #docs by casiepa. View the logs.
5 years ago
#2
@
5 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
@
5 years ago
- Milestone changed from Awaiting Review to 5.6
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#4
@
5 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
@
5 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.
#6
@
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.
4 years ago
#9
@
4 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.
4 years ago
#11
@
4 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
@
3 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 be written without published; so both dates should be handled by different properties.
This ticket was mentioned in PR #8175 on WordPress/wordpress-develop by @pbearne.
2 months ago
#13
- Keywords needs-refresh removed
…ndles dates and times associated with posts. Instead of referring to the "date the post was written," the functions and filter descriptions now refer to the "date of the post." This change likely reflects a move towards greater flexibility in how dates are used, accommodating scenarios where the displayed date might not strictly correspond to the writing date (e.g., scheduled posts, backdated posts, or content where the "date" represents something other than creation).
Here's a breakdown of the changes:
- Function and Filter Descriptions: Docblocks for
the_date()
,get_the_date()
,the_time()
,get_the_time()
,get_post_time()
,the_weekday()
, andthe_weekday_date()
have been updated to reflect the new "date of the post" language. The filters associated with these functions have also received corresponding updates. This change is primarily semantic.
get_post_time()
Docblock Update: The description forget_post_time()
is also updated, clarifying that the$format
parameter accepts standard PHP date formats or 'G' (Unix timestamp) or 'U' (seconds since the Unix Epoch). The wording emphasizes that this function retrieves the *localized* date of the post.
The changes don't introduce new functionality or modify existing behavior. They clarify the purpose of these functions and make the documentation more accurate and flexible. The shift to "date of the post" acknowledges that the displayed date might have different meanings depending on the context.
#14
@
2 months ago
- Keywords good-first-bug removed
- Milestone changed from Future Release to 6.8
- Owner changed from SergeyBiryukov to pbearne
- Status changed from reviewing to accepted
#15
@
2 months ago
- Keywords changes-requested added
Hi @pbearne thanks for the PR. This looks good on my side. I spotted a few glitches though. I added them in your PR :)
@audrasjb commented on PR #8175:
2 months ago
#18
committed in https://core.trac.wordpress.org/changeset/59691
Docs: Various date/time functions are returning the date/time the content was published, not written