: strtotime() expects parameter 1 to be string, object given in on line

Home Forums Calendar Products Events Calendar PRO : strtotime() expects parameter 1 to be string, object given in on line

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1069624
    Rex
    Participant

    Following up on the discussion here (https://theeventscalendar.com/support/forums/topic/warning-strtotime-expects-parameter-1-to-be-string-object-given-in/), this error message is being displayed on all calendar feeds on my site home page. This development site has been posted on two different servers at the following urls:

    http://rexchannel.com/wp_dev/index.php
    http://053.f42.myftpupload.com/index.php

    The error DOES NOT occur in my local development environment. The complete error message is:

    : strtotime() expects parameter 1 to be string, object given in on line

    Warning/home/content/p3pnexwpnas04_data01/66/2773966/html/wp-content/plugins/the-events-calendar/src/Tribe/Query.php217

    Here is an example of the code I used to create the calendar feeds:

    <?php
    global $post;
     
    // retrieve the next 5 upcoming events
    $events = tribe_get_events( array(
    	'start_date' => new DateTime(),
    	'tribe_events_cat' => 'services'
    ) );
     
    foreach ( $events as $post ) {
    	setup_postdata( $post );
     
    	echo '<div class="event_item">';
    	echo '<div class="event_date">' . tribe_get_start_date() . '</div>';
    	echo '<h4><a href='.get_the_permalink() . '>' . get_the_title() . '</a></h4>';
    	echo '</div>';
    } ?>

    Updating to the latest version of The Events Calendar has had no effect on the problem.

    Thanks in advance for your help!

    #1069634
    Rex
    Participant

    It seems that in an effort to remove comments from my code, I accidentally removed a line. Here is the corrected code:

    <?php
    global $post;
     
    $events = tribe_get_events( array(
    	'posts_per_page' => 10,
    	'start_date' => new DateTime(),
    	'tribe_events_cat' => 'services'
    ) );
     
    foreach ( $events as $post ) {
    	setup_postdata( $post );
     
    	echo '<div class="event_item">';
    	echo '<div class="event_date">' . tribe_get_start_date() . '</div>';
    	echo '<h4><a href='.get_the_permalink() . '>' . get_the_title() . '</a></h4>';
    	echo '</div>';
    } ?>
    #1069646
    George
    Participant

    Hey @Rex,

    Thanks for posting your code here. I’m wondering if changing the ‘start_date’ argument in your use of tribe_get_events() alone might help here–try this instead of your current use of new DateTime():

    'start_date' => current_time( 'Y-m-d' ),

    Let me know if this helps!

    George

    #1069660
    Rex
    Participant

    YES! This fixed the problem. Thank you so much for your quick response.

    Rex

    #1069759
    George
    Participant

    Nice! Best of luck with your site 🙂

    — George

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘: strtotime() expects parameter 1 to be string, object given in on line’ is closed to new replies.