Support

Account

Home Forums General Issues Date Picker for Coupon use

Solved

Date Picker for Coupon use

  • 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’);	
    	
    }
    
    
  • Perfect. Thx Jonathan!

  • No problem!

    Don’t hesitate to create another topic if you need further assistance 🙂

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

The topic ‘Date Picker for Coupon use’ is closed to new replies.