Home Forums Front-end Issues Show text after date gone


Show text after date gone

    • xaibi

    • December 4, 2019 at 12:52 am

    I am here to ask that I created a date picker field with name of the Last Date. Is it possible that when date passed it will show text and hide the date?

    • xaibi

    • December 11, 2019 at 11:34 pm

    Any help, 1 week gone.

  • You did not really give a lot to go on, but yes, it would be possible.

    You get the value, you compare it to the current date and do something based on the comparison.

    $today = date('Ymd');
    $date = get_field('date_field', false, false); // get unformatted value
    if ($date < $today) {
      // date is passed
    } else {
      // date is not passed
    • xaibi

    • December 17, 2019 at 9:38 pm

    Actually, I am using ACF and I create a date field with the name of (LAST DATE). So I just want to show a specific text after or replace the field.

    For Example, I added the last date 15 Dec 2019 and it’s showing me on my site. When 15 Dec 2019 gone then it will show like this.

    Replace The date: Job Expire

    • xaibi

    • December 17, 2019 at 10:26 pm

    Ok I fixed it, thanks.

    $currentdate = new DateTime();
    $date = get_field('last_date', false, false);
    $date = new DateTime($date);
    if ($currentdate > $date) {
      echo '(Job Expire)';  
    } else {
      echo get_field( 'last_date' );
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.