Arrow

Having the countdown treat a day as midnight-to-midnight | Peter's Date Countdown | Forum

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


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

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

Reply to Post Add a New Topic
UserPost

2:11 pm
April 5, 2008


Peter

Admin

posts 710

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…

Reply to Post

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

Guest Name (Required):

Guest Email (Required):

HTML Editor
Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
9 + 6