countup

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
Vietboy
Forum Commoner
Posts: 41
Joined: Mon Dec 01, 2003 10:59 pm

countup

Post by Vietboy »

I don't see any scripts that count up.. mostly i see countdown

Any one has the code for count up?

Each day + 1
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Post by Saethyr »

This Should get you close. There are probably much easier ways but I wrote this in a hurry and it seems to qwork, this is good to 2 decimal places.

Code: Select all

<?php
$StartDate = mktime(0,0,0,12,18,2003); //mktime(hour, minute, second, month, day, year)
$DateToday = mktime(date("h, i, s, m, d, Y"));//todays date

$dateDiff = $DateToday - $StartDate;

$NumDays = round($dateDiff/60/60/24, 2);


echo 'Difference in days: ' . $NumDays . '<br />';
?>
Saethyr
Post Reply