PHP countdown with custom field in wordpress -


i want display days remaining till date specified in custom field inside of wordpress. custom field named bewerbungs_frist. i'm using code:

<?php $days = ceil((strtotime("<?php the_field('bewerbungsfrist'); ?>") - time())/(60*60*24));         $s='';         if ($days!=1) {              $s='s';         }         echo $days. " days "; ?> 

as output -1500 days. can't right. can me out?

i solved issue code:

<p>bewerbungsfrist: <?php $date = datetime::createfromformat('ymd', get_field('bewerbungs_frist'));  echo $date->format('d.m.y');?></p> noch <?php $days = ceil((strtotime(get_field('bewerbungs_frist')) - time())/(60*60*24)); echo $days. " tage "; ?> 

you opening wrong php tags between opened tags

try

$days = ceil((strtotime(the_field('bewerbungsfrist')) - time())/(60*60*24)); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -