Arrow

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

Back to the date countdown plugin page

Please consider registering
guest

Log In

Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Having the countdown treat a day as midnight-to-midnight
April 5, 2008
2:11 pm
Peter
Admin
Forum Posts: 841
Offline

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…