• So I have this code that brings me back the timezone on the admin’s email and I must be doing something incorrect because the time I am getting back is not correct. I also notice in each order details in the orders it’s the incorrect time too. I notice that my wordpress posts that I publish immediately are not the correct correct times either, What gives? Everything seems to be 8 hours ahead of my actual time zone.

    Yes, I do have my timezone in my wordpress setting set for Los Angeles time. But the times I get back are not correct at all.

    add_action( ‘woocommerce_email_after_order_table’, ‘woo_timestamp’, 15, 2 );

    function woo_timestamp( $order, $is_admin_email ) {
    if ( $is_admin_email ) {
    date_default_timezone_set(“America/Los_Angeles”);
    echo “The time is ” . date(“h:i:a”);
    }
    }

    https://wordpress.org/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • I tried digging into this, and there seems to be an enormous amount of conflicting info about date and time functions, and timezone issues with PHP and WordPress. Ugh, I can see myself trying to tackle this same issue in the near future.

    Not that I have enough experience with PHP and WordPress yet, but…

    Is the action hook taking place after the email is already generated? It looks like WooCommerce is reverting back to UTC time (which is what it may be set to by default in the server’s PHP.INI file). Los Angeles standard time is 8 hours behind UTC.

    Did you check to see if E_NOTICE or E_WARNING is set after the call to date_default_timezone_set?

    I’d assume that WordPress posting logic would be using your Timezone setting in General Settings, and I figured you probably already checked that.

    If I find anything more definitive, I’ll post here again.

    Thread Starter Ravenous Raven Design

    (@ravenousravendesign)

    I’m realizing that. I actually tried this, but it didn’t work for me. I entered the code both in my htaccess file and in my index.php with no luck of it being fixed. I left it there overnight thinking it would just fix itself, but It didn’t. uuugh.
    http://borishoekmeijer.nl/resolve-current-date-and-time-timezone-issue-in-wordpress/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How Do I Set A Correct Timezone in Email Template’ is closed to new replies.