[CustomPress] CustomPress Date Issue

Hi, I have used the CustomPress plugin to create a deadline date that displays on the frontend. What I have tried to do is use this field to check against today's date and if it is past to expire (visually) on the page.

The problem I am having is that the day and the month from the custompress field are reversed, like an American date, this causes an issue when the day is 26th, for example, and because there isn't a 26th month it defaults the date the 1/1/1971. Obviously, the other issue is that the date just isn't working.

  • Patrick Freitas
    • Staff

    Hi Serena

    I'm sorry to hear that you are having this problem.

    Are you using the Date Picker filed?

    If so, you can change the Date Format on the DropDown box.

    Wouldn't you mind, please, grant the support access, and I can take a closer look for you?

    1. Log in to the WordPress Admin Panel for your site (go to the Network Admin dashboard if on Multisite), and then navigate to the “Support” page from the WPMU DEV menu item (WPMU DEV > Support).

    2. Click the “Grant Support Access” button in the Support Access panel.

    You can follow the steps on https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-5.

    Let me know when support is granted.

    Best Regards,
    Patrick Freitas

  • Serena
    • WPMU DEV Initiate

    I have granted you access.

    The issue is in the backend. I have a little script to compare one date with another but the date from custompress isn't working properly, no matter what I try and do. The month and day are the wrong way around and then causing an error. What am I doing wrong?

    $deadline_vd = get_post_meta( get_the_ID(), 'ct_Deadline_D_datepicker_7975', true);

    $today = date("Y-m-d");
    //$expirationdate = strtotime($deadline_vd);
    $expiredVac = date("Y-d-m", $deadline_vd) ;

  • Patrick Freitas
    • Staff

    Hi Serena

    Thank you for the code,

    Let me know, if I got the right point, you would like to compare the current date to the time picker and create your function.

    $deadline_vd = get_post_meta( get_the_ID(), 'ct_Deadline_D_datepicker_7975', true);
    $now = new DateTime();
    $today = $now->format('d-m-Y');
    echo "<h1>Plugin Date Piker: ".$deadline_vd."</br>Today: ".$today."</h1>";
        echo "<br><br><br><h1> Same Date</h1>";
        echo "<br><br><br><h1> Different Dates</h1>";

    The above code might help you with this.
    Best Regards,
    Patrick Freitas

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.