Date format for Expire date

This topic contains 6 replies, has 3 voices, and was last updated by  amweb 5 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #506694

    amweb
    Full Member
    Post count: 55

    Dear GD support team,

    As asked by Alex on my previous support request (see https://wpgeodirectory.com/support/topic/missing-expiration-field-in-back-end/#post-506654), I open a new request concerning the date format of the Expire date field for CPTs:
    Is it possible to add the standard date format configured in WordPress settings to the “Date Format” dropdown, or at least a “Custom” option where we can add our own custom formatting?
    Right now I see seven different options (see screenshot), but unfortunately none of them corresponds to my needs (nor to the settings used in the rest of the website).

    NB: It would be very nice if we could have one consistent date/time format throughout the whole system. This is not my first support request concerning date/time formatting and translation, but I really hope that it will be the last 😉

    Thank you and kind regards,
    Aron

    #506762

    Alex Rollin
    Moderator
    Post count: 27815

    Additional custom input formats can be added with a customization using a filter: https://wpgeodirectory.com/docs-v2/addons/events/#custom-input-format

    Matching the expire date to the event date is unfortunately not currently available.

    I have taken this up as a suggestion and will share it with our development team to see whether we can work on this in the near future.

    Please feel free to make a new topic if you need help with anything else.

    #506773

    amweb
    Full Member
    Post count: 55

    Hi Alex,

    Thank you for the reference to the snippet, but unfortunately this does not work for the “Expire date” field (nor does it add an option to the dropdown shown in my previous screenshot, located in the settings for the “Expire date” field in the backend, under Events > Settings > Custom fields > Expire date).

    I used

    $formats[] = 'd.m.Y';

    removing the comment and adding the missing semicolon but nothing has changed.
    Do you have any other suggestion?

    Thank you also for having taken up my suggestion about automatic expiration date based on the event end date.

    Kind regards,
    Aron

    #506785

    Alex Rollin
    Moderator
    Post count: 27815

    Unfortunately a snippet for expire date format is not available at this time but I will inquire with the developers if that is something they can work on soon.

    #506789

    amweb
    Full Member
    Post count: 55

    Thank you Alex, I will keep an eye open for a developer feedback on this topic.

    Have a nice weekend,
    Aron

    #507093

    Kiran
    Moderator
    Post count: 7069

    Hi amweb,

    1) Add following snippet

    
    
    /**
     * Change date format for custom field type date.
     */
    function gd_snippet_20190909_date_formats( $date_formats ) {
    	$date_formats[] = 'd.m.Y';
    
    	return $date_formats;
    }
    add_filter( 'geodir_date_formats', 'gd_snippet_20190909_date_formats', 20, 1 );

    2) Go to CPT(Ex Places) > Settings > Custom Fields > Expire Date > Choose date format to “d.m.Y” > Save
    3) Go to add/edit/view listing page, it will show date format to d.m.Y.

    Thanks,
    Kiran

    #507106

    amweb
    Full Member
    Post count: 55

    Hi Kiran,

    Perfect, thank you, that worked like a charm!

    Kind regards,
    Aron

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount