countdown in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bond0bhave
Forum Newbie
Posts: 5
Joined: Wed May 29, 2002 1:55 am
Location: Durban, South Africa

countdown in php

Post by bond0bhave »

I want to make a countdown in php, but I want it to onlyy work during working hours(8-5), and excluding weekends.

Have no idea how to even start.

Thanks
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Ok not sure how to exclude hrs of 8-5. Maybe a portion of the script could check the current time and not display certain functions.

Code: Select all

<? 
$day = 1;      
$month = 6;   
$year = 2003;     
print ((int)((mktime (0,0,0,$month,$day,$year) - time(void))/86400) . " day(s) to event."); 
?>
This will get you day(s) left to an event. Are you looking for hour(s) to an event? I can write something quick for that also.
Last edited by Kriek on Wed May 29, 2002 8:11 am, edited 1 time in total.
bond0bhave
Forum Newbie
Posts: 5
Joined: Wed May 29, 2002 1:55 am
Location: Durban, South Africa

Post by bond0bhave »

thanks

I need it to countdown in hours how much time left a person has from the time a job was started.

Will play around witht that one though
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

OK adding the hour(s) is easy.

basicly we add the Variable $hour = 12 into the mix.

Code: Select all

<?
$day   = 1;     
$month = 6;    
$year  = 2003;   
$hour  = 12;     
$event = "Till job is done"; 

  $calculation = ((mktime ($hour,0,0,$month,$day,$year) - time(void))/3600);
  $hours = (int)$calculation;
  $days  = (int)($hours/24);

?>
Then we output it like this. Notice I just added $event to make it easier.

Code: Select all

The date is <?=(date ("l dS of F Y h:i:s A"));?>.
It is <?=$days?> days until <?=$event?>.
It is <?=$hours?> hours until <?=$event?>.
bond0bhave
Forum Newbie
Posts: 5
Joined: Wed May 29, 2002 1:55 am
Location: Durban, South Africa

Post by bond0bhave »

thanks, that really helps, will give it a bash
Post Reply