Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 130709

To Create Dynamic Countdown using Advanced Custom Fields Plugin

$
0
0

Replies: 0

Hi,
I am creating a custom bootstrap based wordpress theme. I have installed ACF Pro to add some custom fields. I added a Date Picker using Advanced Custom Field Plugin.

I am creating a user based theme where users will display their projects for certain period. I want to add a countdown function that will fetch the date dynamically from the custom field in database and will get converted into countdown. So that people will know how long the project will last on the website.

For that I added following PHP code in single.php file:

<?php
$date = strtotime(“Jan 28, 2018”);
$remaining = $date – time();
$days_remaining = floor($remaining / 86400);
?>
<span><?php if($remaining >=1) { echo $days_remaining; } else { echo ‘0’; } ?></span>
<p>Days to go</p>

When I add a static date I get the desired result (In above code I have added Jan 28, 2018 as static date).

But I tried many codes to fetch the date from database which i have added through Date Picker but not getting any result. I am getting error.

Plz suggest me the exact code to fetch date.( I am not so good in coding so plz give it in detail.).

Thanks.


Viewing all articles
Browse latest Browse all 130709

Trending Articles