• Resolved mfigatow

    (@mfigatow)


    I’ve tried to use post.post_date and customfield containing the date value in a mail template and I realized that they are always displayed in GMT. Because the local time value is more useful in emails, I’ve added the ‘useLocalTime’ modifier and handling code in src\Types\Parameters\BaseParameter.php:

        public function formatDate($value, $modifiers)
        {
            $waOptions = get_option('wunderauto-general');
    
            $format = null;
            if (isset($modifiers->format)) {
                $format = $modifiers->format;
            }
            if (empty($format) && isset($waOptions['datetimeformat']) && strlen($waOptions['datetimeformat']) > 0) {
                $format = $waOptions['datetimeformat'];
            }
            if (empty($format)) {
                $format = get_option('date_format');
            }
    
            /* MF+ handle useLocalTime modifier */
            $timestamp = $this->toEpoch($value);
            if (isset($modifiers->useLocalTime)) {
           		$timestamp = $timestamp + floatval( get_option( 'gmt_offset', 0 ) ) * HOUR_IN_SECONDS;
            }
    
            return date($format, $timestamp);
            /* +MF */
        }
    

    Take a look on it, if you find it useful, feel free to include it in future releases.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author wundermatics

    (@wundermatics)

    Hi mfigatow,

    Yes, this makes perfect sense. Local time vs GMT dates are more or less completely overlooked at the moment. I’m thinking that the default perhaps should be the other way around. WunderAutomation should to it’s best to always return local time unless a parameter explicitly say otherwise.

    Appreciate your feeback and contribution enormously much. If possible we’d like to hear your take on a few other potential approaches to get the date/time correct.

    Feel free to reach out to us at [email protected] so we can chat.

    Plugin Author wundermatics

    (@wundermatics)

    …completely forgot to mention it. As a band-aid for the problem you describe. The latest version, 1.4.3, has a Add/subtract feature for dates. So in your particular case you could fix the problem using that.

    https://www.wundermatics.com/docs/working-with-date-parameters/

    This should work except for a few issues introduced because of of daylight savings.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Local time instead of GMT’ is closed to new replies.