Hi,
first of all. Fantastic Plugin.
I try to realize a coupon section.
Im using the Date Picker with this code:
$date = DateTime::createFromFormat(‘Ymd’, get_field(‘gultigkeit’));
$datum = $date->format(‘d-m-Y’);
$heute = date(‘d-m-Y’);
if ($datum >= $heute): ?>
If $datum (get_field(‘gultigkeit’) is empty i have an php error.
Ive tried it with isset() and !emplty(). But it didnt work. Hope you have an idea.
Thx in advance
Hi @madmaxy
You should check for the get_field around everything instead. Since otherwise you attempt to create a datetime etc. with no second parameter so $datum wont be empty.
if( get_field('gultigkeit') ){
$date = DateTime::createFromFormat(‘Ymd’, get_field(‘gultigkeit’));
$datum = $date->format(‘d-m-Y’);
$heute = date(‘d-m-Y’);
}
No problem!
Don’t hesitate to create another topic if you need further assistance 🙂