admin管理员组文章数量:1421066
I’m trying to compare two dates (the current date with an ACF datepicker one) to display specific content. What I’m trying to achieve is to display a phrase if the ACF date is lower than the current time (in few words if a service is expired). This is my code:
$dataScadenza = get_field('data_di_scadenza');
$currentDateTime = date('d.m.y');
if($dataScadenza <= $currentDateTime) {
echo '<a href="'.get_field('link_esito').'">';
echo '<button class="vedi_esiti">VEDI ESITI</button>';
echo '</a>';
} else {
echo '<span class="ds_label">data scadenza</span>';
echo '<div class="ds_date">'.get_field('data_di_scadenza').'</div>';
}
where $dataScadenza is the ACF date and $currentDateTime is current date. Both variables have the same output (d.m.y).
What happens is that the comparison is applied only on day number and not on the entire date.
Anyone can help to solve the problem?
Thank you!
本文标签: advanced custom fieldsComparing two dates (ACF and current time)
版权声明:本文标题:advanced custom fields - Comparing two dates (ACF and current time) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745337166a2654094.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论