Skip Navigation

[Resolved] Filter date in view with data from Pro Event Calendar

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.36 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by jurgenK-2 5 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#1297289
screenshot pec date filter2.JPG

I am trying to:
Make a list from events and filter list by date

Link to a page where the issue can be seen:
hidden link

I expected to see:
Filtered List

Instead, I got:
Full list

The issue comes from the fact that dates are saved in the form of "2019-05-22 18:30:00" instead of timestamp.

Here I could fix the startdate of the list:
https://toolset.com/de/forums/topic/how-to-sort-by-date-with-pro-event-calendar/#post-1296011

I hoped this would also effect the frontend date filter (see screenshot), but it doesn't. Is there a solution also for the date picker to change the date format into a timestamp?

#1297365

Hi Jurgen,

Thank you for contacting us and I'd be happy to assist.

In case the Pro Event Calendar plugin doesn't store its date fields in a UNIX timestamp format, I'll recommend adding a new date type field for your event posts, through Toolset Types plugin. The benefit of this approach would be that you'll be able to make use of the Toolset View's builtin date filters on that new field, without any further customizations.
( https://toolset.com/documentation/user-guides/date-filters/ )

This new date type field will need to store the same date, as stored in the Pro Event Calendar plugin's field, but since it will be storing dates in UNIX timestamp format, you won't face the same limitations.

The admin can either fill these dates manually in the admin area while creating or editing an event or you can programmatically update it, as explained in this guide:
https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1297551

My issue is resolved now. Thank you!

It's a good idea to update automatically a new field in the right format.

In function.php I use:

 function save_start_date ( $post_id, $post ){
    if ( 'pec-events' == $post->post_type ) {
        $date = get_post_meta( $post_id, 'pec_date', true );
        $now = time();
        if ( !empty($date) ) {
            update_post_meta( $post_id, 'wpcf-startdatum', strtotime ($date) );
        }
    }
}
add_action( 'save_post', 'save_start_date', 30, 2 );