Home Forums General Issues Issue with next year in date picker


Issue with next year in date picker

  • I am using the date picker field on a client’s site.

    I am catching the data with:

    $dateFrom = new DateTime(get_field('date_from'));

    Then outputting with:

    <?php echo $dateFrom->format('j'); ?>
    <?php echo $dateFrom->format('F'); ?>

    It works great UNTIL my client puts in a date that is next year, and for some reason it outputs the date on the website as this year’s equivalent. eg ’26 January, 2016′ in the picker is outputting on the site as ’27 January, 2015′. Why is this happening, please help me.

  • What to you have set as the return format for that date field?

    That’s the value you are using to create the new DateTime object so it needs to be in a format that it understands., to be honest, looking at that page I can’t say if 26 January, 2016 is a value it understands, I find it a bit confusing.

    You can also do $dateFrom = new DateTime(get_field('date_from', false, false)); the second false tells ACF not to format the value and I know that the unformatted value will work.

  • Thank you so much, that worked perfectly.

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

The topic ‘Issue with next year in date picker’ is closed to new replies.