Back to Community

How to Fix PDF Invoice Date Display Issues in WooCommerce

Content

If the delivery or order date in your WooCommerce PDF invoice is displaying incorrectly—such as showing one day later than the date selected in your admin—you're not alone. This is a common issue that often stems from a conflict between how different plugins handle date formatting and time zones.

Why Does This Happen?

This discrepancy typically occurs when a third-party plugin (like a delivery date plugin) hooks into the PDF invoice to add its own data. The 'PDF Invoices & Packing Slips for WooCommerce' plugin itself does not generate these custom date strings. If the other plugin uses a different function to format the date (for example, using PHP's date() instead of WordPress's timezone-aware wp_date() function), the date can appear offset due to server timezone settings.

How to Troubleshoot and Resolve the Issue

1. Contact the Other Plugin's Support

The most straightforward solution is to contact the support team for the plugin that provides the date functionality (e.g., 'Order Delivery Date Pro for WooCommerce'). They are best positioned to know how their date information is added to the PDF and can advise on a fix. Ask them specifically which function they use to output the date in the PDF document.

2. Investigate with Code (For Developers)

If you have coding skills, you can investigate the source of the problem yourself. You need to locate the code that adds the delivery date to the PDF invoice. This code is likely using one of the PDF plugin's action hooks, such as wpo_wcpdf_after_order_data.

Once you find the function, check if it uses date() or gmdate(). These functions do not account for the WordPress timezone setting. The fix is to replace them with the WordPress function wp_date(), which correctly formats the date based on your site's timezone.

// Example of incorrect code that might cause an offset
echo date( 'Y-m-d', $timestamp );

// Corrected code using the WordPress timezone
echo wp_date( 'Y-m-d', $timestamp );

3. Double-Check Your Timezone Settings

While the issue is most likely in the other plugin's code, it's always good to confirm your WordPress timezone setting is correct. You can find this in your WordPress admin under Settings > General.

Conclusion

An offset date in your PDF invoice is almost always a conflict with another plugin's custom code. The solution involves reaching out to that plugin's developers or modifying their code to use WordPress's proper timezone functions. By following these steps, you can ensure the dates on your invoices accurately reflect your and your customers' expectations.

Related Support Threads Support