NO BUG: Countdown timer NaN error in Bricks 1.7.3

Browser: Firefox 113.0.1
OS: Linux
URL:
Broken - NaN:

Works:
same prefix, page name the-black-dahlia-murder/

I have what seems like a bug with the countdown timer, which is important for a new build that I’m doing.
Interestingly, it’s occurring ONLY ON SOME POSTS (about half) and I can’t figure out the issue.

  1. I’m using the bricks/element/settings filter to pass _EventStartDate to countdown timer element.
    (followed this: Some Powerful Filter Hooks in Bricks Builder You Might Not Know - Pure Coding Knowledge Sharing Blog)

  2. (Probably unrelated, maybe my snippet loaded too early/late) I couldn’t figure out why can I not use any of these functions to get the ID, they return zero or null. Those didn’t work so I couldn’t use the functions I wanted to (i.e. tribe_get_event_date).

//echo ‘----';
//global $post;
//$luid = $post->ID;
//echo $luid;
//echo '----';
//$luid = get_the_ID();
//echo $luid;
//echo '----
’;
//$luid = the_ID();
//echo $luid;

  1. So I got it to work using get_post_meta:

$lu_event_start_date = get_post_meta( $element->post_id, ‘_EventStartDate’, true );

  1. That seems to work fine to get the date, so I have that echo’d to page for testing.

Now the countdown timer works fine on half of the posts.

  1. For other (approximately half) posts which use this same template, the countdown timer shows NaN days, NaN hours, NaN minutes, NaN seconds.

However per my echo on the page (the top line) you can see that the date is retrieved correctly.

So I don’t know what is going wrong after retrieving this date in the correct format, during rendering of the countdown timer, ONLY FOR SOME of the posts (cpt tribe_events).

For example, you can just go to the home page and click on the upcoming events in slider. The first 2 upcoming events the countdown timer works fine.

On the next 3, it’s broken, even though the date is returned correctly as shown in my echo output on the page.

I don’t know how to debug this. I’ve analyzed the data records looking for any differences, and am unable to see any differences which might explain why it works on certain posts and not others.

  1. My snippet:
    add_filter(‘bricks/element/settings’, ‘lu_change_countdown_element_settings’, 10, 2);
    function lu_change_countdown_element_settings($settings, $element)
    {
    // Usually you will check element id here to target the correct element
    if ($element->id !== ‘wiaxzu’) return $settings;

    //***THIS WORKS - MOST OF THE TIME
    $lu_event_start_date = get_post_meta( $element->post_id, ‘_EventStartDate’, true );
    echo $lu_event_start_date; //***JUST FOR TESTING - SHOW WE HAVE THE CORRECT DATE

    //***FINALLY CHANGE THE ELEMENT DATE FIELD
    $lu_event_start_date_object = new DateTimeImmutable($lu_event_start_date, wp_timezone());
    $settings[‘date’] = $lu_event_start_date_object->format(‘Y-m-j H:i:s’);
    return $settings;
    }

  2. I’ve created an admin user for you to investigate if you need to! Just shoot me an email that I can reply to with your username/pass!
    This is an isolated server (ec2 instance) for testing, with nothing live on it, so i could also give you phpmyadmin access if necessary, but I’m assuming you know how to debug this on the front end (or know of a known issue already).

Thank you!

Hey Loren,

thanks for your report.

Since I could not reproduce the issue (see demo) it would be great if you could provide me with some temporary credentials to your site. Please send them (and a link to this forum thread) to help@bricksbuilder.io using the email you used to purchase Bricks.

Best,

André

Hello Andre,
Your admin credentials are towards the bottom of the email that I already sent a few hours ago after I realized I couldn’t add the links or screenshots on the forum here (as a newbie).

Thanks for your quick response!
I’ll be available for another half hour or so in case you have any questions.

Hey Loren,

credentials seem to work but the site wants some additional verification. I do not receive any mail though. Can you please have a look again?

Thanks,

André

Hi Andre,
I used the link to verify.
Try now

Hey Loren,

same problem. There seems to be an additional layer of security somehow.

But before I dive in deeper. Can you try to change the date format you use in your snippet from Y-m-j H:i:s to Y-m-d H:i:s and see if that changes anything?

Best,

André

I just deactivated wordfence, shouldn’t be any more security issues.
(doesn’t matter, this is just an isolated dev environment)

Hey Loren,

did you try the date format change from my last comment?

Best,

André

Hey Loren,

I changed it and this fixes the issue. :slight_smile:

Best,

André

no i don’t want to step on your toes if you’re trying to log in, and I have to wake up for work in 4 hours so i must sign off.
wordfence is disabled you should be in the clear.
thank you!

ahh one leading zero, explains why dates at beginning of next month worked.
i’d still call that a bug… but anyway thanks for fixing!
much appreciated.
-Loren

Please forward to Itchy to update guide at

Thanks!