Date format when showing meta key value

Hi, I'm setting up a site using Event+ plugin, and I am styling the grid with a plugin called The Grid builder.
It works okay, but I have a problem showing the date in the format: j. F Y kl. G:i
The way I trigger the event start date, instead of the post date, is using the meta data key: incsub_event_start but it shows the date in US format and with seconds. (I have attached a screenshot, showing the diffence in date formats) Is there any way I can change the metadata to use the other format, or could there be another way of showing the correct date format on the listing of the post?

And how do I change the from start date to end date in e.g. widgets to other language and time format without seconds?

Last question: is the plugin supported for translation with e.g. WPML?

  • Kasia Swiderska

    Hello Johnny,

    The way I trigger the event start date, instead of the post date, is using the meta data key: incsub_event_start but it shows the date in US format and with seconds.

    It looks like that plugin is pulling pure date value from database. I tried to check options there but your subistes are not accessible - when I tried to check them I was asked to login. Can you check that and let me know (or leave login and pass for subsite where you have Events installed in support message in WPMU DEV Dashboard)? I'm not able to test The Grid plugin on my site because that is paid plugin.

    And how do I change the from start date to end date in e.g. widgets to other language and time format without seconds?

    Widget "Upcoming events" uses date format declared in General Settings of WordPress.

    I tested that on my site and it pulls date in correct, same as in Settings. If you confirmed that Settings are correct but widget is still showing wrong date please please run a quick plugin/theme conflict test as illustrated in getting support manual (flowchart). Let me know how it goes.
    http://premium.wpmudev.org/manuals/using-wpmu-dev/getting-support/

    As for translation, you can download files (po and mo) with translation for your language here http://premium.wpmudev.org/translate/projects/eab and then upload it to languages/plugins - if translation is not completed for your language you can use free app https://poedit.net/
    to finish it.

    Last question: is the plugin supported for translation with e.g. WPML?

    It should work with WPML (or PolyLang) - I haven't tested it heavily because its third party plugin - we did have some reports two years ago about incompatibility on their site but nothing new from last year.

    kind regards,
    Kasia

  • Johnny

    Hi... thank you for your quick answer, very appreciated by the help in here.. you are really a cool bunch of people :wink:
    I have posted a user/password, and I have read your answer too. It's not a problem to get the formatting right on the date, but the field I'm referring to 'incsub_event_start' seems to post directly from the DB table, without formatting the string to another date format, so if it could post the date as j. F Y kl. G:i in the DB perhaps it would do, or if there is another way to fetch the start of the event in the grid with the formatted date it would be nice.

    Another solution I tried today, was to activate the add-on Additional Fields and add another text-field, they could enter the date as well.. but it doesn't show in the Add or edit event...

  • Rupok

    Hi Johnny,

    the field I'm referring to 'incsub_event_start' seems to post directly from the DB table, without formatting the string to another date format, so if it could post the date as j. F Y kl. G:i in the DB perhaps it would do

    I'm not exactly sure how it can be achieved, so I'm pinging one of our SLS (Second Level Support) guys regarding this. I believe, he will be able to come up with a workaround.

    Please keep in mind, our SLS guys work round the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback.

    Another solution I tried today, was to activate the add-on Additional Fields and add another text-field, they could enter the date as well.. but it doesn't show in the Add or edit event...

    The add-on available in Events+ plugin is "Additional registration fields". Are you referring to this one? Or am I missing something? If you are referring to this one, then can you please tell us where this is not showing? Front-end Add/Edit event section? Those fields are for RSVP registration, so I am not sure how you are planning to utilize that field. Can you please give us some idea?

    I'll update you as soon as I get something from our SLS guy. I'm looking forward to resolving this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Rupok

    Hi Johnny,

    I've got an update from Panos. He has given us a code which will fetch "incsub_event_start" meta value, format that value and store inside a new meta key "incsub_event_start_formated". You can use this code by creating a MU Plugin. For creating a MU Plugin, create a folder named "mu-plugins" inside your "wp-content" folder. Then inside that "mu-plugins" folder, create a file with any name and with a .php extension. Now paste the code inside that file and save.

    <?php
    function wpmudev_save_incsub_event_start_formated($post_id){
        global $post; 
    
        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
        if ( !current_user_can( 'edit_post', $post_id ) ) return;
    
        if ($post->post_type != 'incsub_event'){
            return;
        }
    
        $incsub_event_start = is_array( $_POST['incsub_event_start'] ) ? $_POST['incsub_event_start'][0] : $_POST['incsub_event_start'];
        $datetime = date_create( $incsub_event_start );
        $date = date_format( $datetime, " j. F Y" );
    
        update_post_meta( $post_id, 'incsub_event_start_formated', $date );
    
    }
    add_action('save_post','wpmudev_save_incsub_event_start_formated');

    For getting more idea on mu plugins, you can go through this article: http://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    After creating this MU Plugin, please create a new event and check if it's working. If it works perfectly for your new event, then we will provide you code for updating all previous events.

    Please let us know how it goes. I'm looking forward to hearing from you and resolving this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Panos

    Hey Johnny ,

    In the first snippet we didn't include the event time, apologies for that !

    Could you try replacing the previous one with the one that follows:

    function wpmudev_save_incsub_event_start_formated($post_id){
    	global $post; 
    
    	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
    	if ( !current_user_can( 'edit_post', $post_id ) ) return;
    
        if ($post->post_type != 'incsub_event'){
            return;
        }
    
        $incsub_event_start = is_array( $_POST['incsub_event_start'] ) ? $_POST['incsub_event_start'][0] : $_POST['incsub_event_start'];
    
        $incsub_event_start_time = '00:00';
        if( isset( $_POST['incsub_event_start_time'] ) ){
    	    $incsub_event_start_time = is_array( $_POST['incsub_event_start_time'] ) ? $_POST['incsub_event_start_time'][0] : $_POST['incsub_event_start_time'];
    	}	
    
        $datetime = date_create( $incsub_event_start . ' ' . $incsub_event_start_time );
    	$date = date_format( $datetime, " j. F Y G:i" );
    
    	update_post_meta( $post_id, 'incsub_event_start_formated', $date );
    
    }
    add_action('save_post','wpmudev_save_incsub_event_start_formated');

    It contains the time value and it should be in G:i format. Please let us know how this goes for you!

    Thanks!
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.