#18361 closed defect (bug) (invalid)
get_gmt_from_date() returns incorrect time for "0000-00-00 00:00:00"
Reported by: | danielbachhuber | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Date/Time | Keywords: | |
Focuses: | Cc: |
Description
When you pass "0000-00-00 00:00:00" to get_gmt_from_date(), it returns the current time with GMT offset. Instead it should return the original nonsense time (possibly altering format if there's an alternate time format referenced).
Backstory: We have a plugin that allows users to create custom statuses. It uses the partially completed custom status API and additional code we've written. In the WordPress.org forum, a bug was reported where if they use a custom status with a post, the post time is set. Currently, they have to manually edit the timestamp of the post before publishing in order for it to be set to the proper publication date (instead of 5 days ago when they originally created it).
The origin of the problem is line #2506 in wp-includes/post.php. The post statuses to receive timestamps should be whitelisted instead of blacklisted. Because the custom statuses aren't a part of the blacklist, they receive a GMT timesteamp.
After looking into this further, I realized $post_date is passed to get_gmt_from_date(), not $post_date_gmt with the nonsense date. I'm closing this ticket in favor of #18362