Arrow


Forum : Having the countdown treat a day as midnight-to-midnight

Back to the date countdown plugin page
Current User: Guest
Search 
Search Forums:


 




Having the countdown treat a day as midnight-to-midnight

Add a New Topic Reply to Post
UserPost

2:11 pm
April 5, 2008


Peter

Admin

posts 518

This is a question I got via e-mail:

I can’t get the countdown to show actual “sleeps” per se. In other words.. I think you are defining sleeps as every 24 hours?? And as such, I have one event at 6pm on the 10th and one event the following morning at 8am yet they both show the same number of winks or sleeps.

My website is http://www.hotforwords.com lower right corner you’ll see the countdown.

Is there something I can tweak to have the winks related to say before and after midnight?

Will you be using countdowns by day only ($showhours and $showminutes settings as “false”)? If so, you can find this code:

// subtract desired date from current date and give an answer in terms of days
$remain = $dc_timestamp – (time() + $timediff * 3600);

And replace the $remain line with this:

$remain = ceil(($dc_timestamp + date('Z')) / 86400) * 86400 – date('Z') – (time() + $timediff * 3600);

Also, find this code:

if (!$showhours) {
$remain = ceil($remain / 86400);

And replace the $remain line with this:

$remain = floor($remain / 86400);

The two changes above should treat all dates as if they occur at midnight the same day, while still displaying them as the correct time:

In other words, suppose your event was on a Sunday at 8pm. On Saturday at 11pm, it says “1 day remaining”. On Sunday at 12:01am it will display “0 days remaining”.

If you also want to have hourly and minute countdowns, then it gets more complicated with a bit more tweaking…

Add a New Topic Reply to Post


Reply to Topic: Having the countdown treat a day as midnight-to-midnight

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 4 + 12        (Required)

Topic Reply:


 
© Simple:Press Forum – Version 3.1.4 (Build 357)