Get event's date & time in SQL time format

Home Forums Calendar Products Events Calendar PRO Get event's date & time in SQL time format

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1017411
    Daniel Eizik
    Participant

    Hi,
    First of all, I’m using the Events Calendar Pro plugin with Avada.
    I want to add the countdown shortcode to the single event page. I managed to add it and my only problem is that the shortcode needs the event’s date and time in SQL time format (YYYY-MM-DD HH-MM-SS) (E.g. 2016-05-10 12:30:00).
    How can I get it so that I can add it on the single-event.php page?

    Thanks,
    Daniel.

    #1017481
    Brian
    Member

    Hi,

    Thanks for using our plugins. I can try to help out here, but might not be able to provide everything for a feature we do not provide.

    This following coding should work in the single-template.php to get the start date format it to

    $startDate_mysql = strtotime( get_post_meta( $event_id, '_EventStartDate', True ) );
    $startDate_mysql = date( 'Y-m-d H:i:s', $startDate_mysql );

    Then you could use $startDate_mysql wherever you need the date to be placed.

    Thanks

    #1017533
    Daniel Eizik
    Participant

    Hi Brian,
    Thanks for your comment but I couldn’t understand where I should try and implement this code.
    As you wrote, I assume all I need is just to have a variable which contains the event’s date and time in this format.

    Would appreciate any help you can give me.

    Thanks,
    Daniel.

    #1017539
    Daniel Eizik
    Participant

    I tried inserting this code in the single-event.php file which is in my theme folder and than add this variable to the same page but all I got is this date and time: 1970-01-01 00:00:00
    So I guess there’s a problem with the code you gave me or I’m not inserting it in the right place (Which is probably more likely).

    Thanks again,
    Daniel.

    #1017826
    Brian
    Member

    Hi,

    I updated the coding again. I realized I did not have the correct variable in the 2nd line.

    That should work better now.

    #1017879
    Daniel Eizik
    Participant

    Thanks Brian.
    Your solution is good but I had to change the _EventEndDate TO _EventStartDate.
    I’m sure it may help someone if you correct the code.

    Thanks again for your help,
    Daniel.

    #1017881
    Brian
    Member

    Oh yeah. I missed that.

    Thanks. I fixed it now.

    Since this is marked resolved I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.

    Thanks

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Get event's date & time in SQL time format’ is closed to new replies.