Hi @baxzibi,
Thanks for reaching out and for outlining the steps so clearly.
I tested this on WooCommerce 9.8.2 with WordPress 6.8 and wasn’t able to replicate the issue—draft products are showing a “Date” as expected. Here’s a screenshot for reference:
👉 https://snipboard.io/5RQSFk.jpg
It’s possible we might be looking at a different area or field than you are. When you get a moment, could you please share a screenshot of where the “Create Date” appears missing on your end? That’ll help us pinpoint exactly what’s going on.
Looking forward to your reply!
Thread Starter
Robert
(@baxzibi)
Thread Starter
Robert
(@baxzibi)
Only post_date_gmt is 0000-00-00 00:00:00 where all other dates are correct:
post_date – correct
post_modified – correct
post modified_gmt – correct
Hi @baxzibi,
Thanks for reaching out. The post_date_gmt column stores the date and time a post is published. For draft posts, this value isn’t set yet, which is why it appears as 0000-00-00 00:00:00. It only gets filled in once the post is published.
For drafts, only the modified date and time are recorded which is the expected behavior.
Thread Starter
Robert
(@baxzibi)
I’m verry disappointed you response.
In meantime I found article which describe issue.
I know that by SQL request I can fix this by myself, but this is definitely bug, which affecting not only me.
Making update by SQL did not resolve the issue.
https://ryansechrest.com/2013/02/no-value-for-post_date_gmt-and-post_modified_gmt-when-creating-drafts-in-wordpress/
Thread Starter
Robert
(@baxzibi)
SQL UPDATE
-- Update for post_date_gmt
UPDATE wp_posts
SET post_date_gmt = CONVERT_TZ(post_date, '+00:00', '+00:00')
WHERE post_date_gmt = '0000-00-00 00:00:00' AND post_date != '0000-00-00 00:00:00';
-- Update for post_modified_gmt
UPDATE wp_posts
SET post_modified_gmt = CONVERT_TZ(post_modified, '+00:00', '+00:00')
WHERE post_modified_gmt = '0000-00-00 00:00:00' AND post_modified != '0000-00-00 00:00:00';
PHP code for functions.php or added in Snippets:
add_action('save_post', function ($post_id, $post, $update) {
// Wyklucz autosave, revision, trashed i post types bez dat
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (wp_is_post_revision($post_id)) return;
if (get_post_status($post_id) === 'trash') return;
global $wpdb;
$post_type = get_post_type($post_id);
$allowed_types = ['post', 'page', 'product']; // dodaj inne typy jeśli trzeba
if (!in_array($post_type, $allowed_types)) return;
$post_obj = get_post($post_id);
$post_date = $post_obj->post_date;
$post_modified = $post_obj->post_modified;
$post_date_gmt = $post_obj->post_date_gmt;
$post_modified_gmt = $post_obj->post_modified_gmt;
// Uzupełnij tylko jeśli gmt = '0000-00-00 00:00:00'
if ($post_date_gmt === '0000-00-00 00:00:00' || $post_modified_gmt === '0000-00-00 00:00:00') {
// WordPress przelicza strefy automatycznie
$gmt_post_date = get_gmt_from_date($post_date);
$gmt_post_modified = get_gmt_from_date($post_modified);
$wpdb->update(
$wpdb->posts,
[
'post_date_gmt' => $gmt_post_date,
'post_modified_gmt' => $gmt_post_modified
],
['ID' => $post_id]
);
}
}, 10, 3);
@mosesmedh and @mahfuzurwp
And No guys, was not resolved by support. This issue still required correction.
This is system fault described below:
https://ryansechrest.com/2013/02/no-value-for-post_date_gmt-and-post_modified_gmt-when-creating-drafts-in-wordpress/
Hi @baxzibi,
Thanks for following up and for sharing the detailed info along with that article—very insightful.
You’re absolutely right that this behavior stems from how WordPress handles drafts at the database level. Specifically, post_date_gmt isn’t populated for drafts because WordPress only assigns that timestamp when a post is published. While this does affect how some systems reference or sort draft products, it’s part of WordPress core behavior and not something WooCommerce directly controls.
We understand how this can be frustrating, especially when it impacts your workflow. Since this relates to core post data handling in WordPress, we recommend sharing your findings directly with the WordPress core team, as they’re best positioned to address or reconsider this logic. You can do that here:
👉 https://core.trac.ww.wp.xz.cn/
Thread Starter
Robert
(@baxzibi)
Zee
(@doublezed2)
Hello Robert,
Thank you for your reply.
I understand you have created a ticket at https://core.trac.ww.wp.xz.cn/ticket/63348. I appreciate your contribution to the WordPress community.
If you have any more questions or concerns, feel free to reach out. We are here to help 🙂
Best regards.
If you have a few minutes, we’d love if you could leave us a review: https://ww.wp.xz.cn/support/plugin/woocommerce/reviews/