I've a custom page for Wordpress where I check if a ACF (advanced custom field) date value (sorted m-d-Y) is < = > of date(m-d-Y). If ACF value have 2016 year all work, if year is 2017 function doesn't work.
example of code:
if (get_sub_field('data_inizio') >= date('m-d-Y')) {
}
If I replace date('m-d-Y') with 01-01-2017 work.
Thanks for your help.
You are currently comparing two strings. You can convert them to unix time and compare them that way, or convert the strings to DateTime objects and compare those.
Example of using unix time to figure out if data_inizio date is in past:
if(strtotime(get_sub_field('data_inizio')) <= time()) {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With