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?
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
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 );