Customize WooCommerce Admin Orders Date Format

Sometimes when providing support for WooCommerce at WooThemes we have strange requests, and I got one recently that i wanted to share. It was about the orders date format in the administration. The default format is Y/m/d, and the customer wanted it to be d/m/Y. How to achieve this? Well, simply by using a filter and little function, here is the code to paste in functions.php in the theme folder to make this change:

And here is the result:

orders-date-format

9 responses to “Customize WooCommerce Admin Orders Date Format”

  1. […] Not necessarily 2.1 specific, but Remi Corson posted a tutorial on Customizing the Orders Admin Date Format. […]

  2. PMorgan

    Hi Remi,

    I’m having trouble with this snippet unfortunately. It’s changing the dates of all my orders to 27/2/14!!

    Any ideas??

    Thanks!

  3. davidgrishaver

    Apologies, This is barely related to this post but wanted to get a note to you and I don’t really use twitter. We’d like to add a custom report to the reports admin area. It would use a date customers enter for the product, with the add-ons extension to graph the orders instead of the order date. In our case it’s the date of a helicopter tour (paradisecopters.com). It would be really useful to sort and graph the orders by this add-on date instead of the order post date because we could then see revenue based on when the flight will take place. Most people don’t book for the same day, but for a future date. I wonder if there’s a slick way to achieve this goal? Maybe even an way to override the date used in the short term would be cool, and educational.

    Hey, if you’d like to discuss this feel free to contact me dgrishaver at g-m-a-l dot c-o-m?

    1. that shouldn’t be too complex to do, however i don’t really do custom custom jobs

  4. GeekSpecialties

    This is not working with WP 4.0
    After updating to WP 4.0 the woocommerce order date field is empty with this code in my functions.php file.

    // change default admin orders date format
    add_filter( 'post_date_column_time' , 'woo_custom_post_date_column_time' );

    function woo_custom_post_date_column_time( $post ) {
    $h_time = get_the_time( __( 'm/d/Y', 'woocommerce' ), $post );
    return $h_time;
    }

  5. paulb

    @GeekSpecialties

    Need to change the above function a bit.
    This one i found works from Woothemes Support – Show Time

    Just need to change the m/d/Y fields.

    eg.


    add_filter( 'post_date_column_time', 'custom_post_date_column_time', 10, 2 );
    function custom_post_date_column_time( $h_time, $post ) {
    return get_the_time( __( 'd/m/Y', 'woocommerce' ), $post );
    }

  6. smurphy01

    Thank you for your blog. Can you tell me how to change the format for the “WooCommerce Checkout Field Editor ” Date fields. Even though my WordPress date format is m-d-Y the dates when using a Date picker type is Y-m-d. Is there a filter I can add to change the default format of the WooCommerce Checkout Field Editor ?

    -Sheila

  7. JamesB

    Hey Remi,

    This seems to cause a problem with a few orders, whereby the date is shown incorrectly (the day before).

    This screenshot shows the 2nd: http://i.imgur.com/5xYAQhR.png
    But when clicked into the order this correctly shows the 3rd: http://i.imgur.com/PMHS29L.png

    Please also see this screenshot. (It says 12:20AM and shows the 8th August, even though you can see in the code, correctly, the 9th): http://i.imgur.com/py0NrPD.png

    Is there a fix for this? Thanks!

    1. JamesB

      This was fixed by replacing:
      function woo_custom_post_date_column_time( $post ) {

      With:
      function woo_custom_post_date_column_time( $h_time, $post ) {

      Thanks Maria @ Woocommerce!

Leave a Reply