0

This is a very simple question, but for some reason having challenges with it. I have set up ACF field group.

I wanted to compare a "date field" to the current "today's date" and "yesterdays" date.

I basically want a variable $color to be 2 different colors based on if the "acf date field" is equal to TODAY or another color if it is equal to yesterday.

Here are the 2 variables I have stubbed out. Can anyone point me in the right direction here ? Thanks!

$curdate = date('F n, Y');
$groom_date = get_sub_field('date_last_groomed');

$color = red; // when $groom_date = TODAY
$color = blue; // when $groom_date = YESTERDAY
  • 2
    3rd party plugins are offtopic here, however, if you found out what the format of the date was, you could eliminate ACF and WordPress entirely from the question and turn it into a generic PHP question that could be answered by anybody. That way even a Joomla developer could help you. Instead you're kind of stuck with only ACF users being able to help :( – Tom J Nowell Jan 3 at 1:55
  • ACF can save and display dates in various formats. If possible, update the field to save the date as an actual timestamp, and PHP can then handle checking which day an item is set for much more easily. – WebElaine Jan 6 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.