View Single Post
  #1 (permalink)  
Old 09-02-2007, 01:21 PM
Nuker Nuker is offline
Registered User
 
Join Date: Sep 2007
Posts: 6
How to calculate new dates

I need calculate the future... mmm

I need add to actual time 300 seconds or 1000 or 3000 seconds and know the future time...

For example:
If the actual time is:

Day 1
Month 9
Year 07
Hour 01
Minuts 54
Seconds 17

add 60 seconds ...

Day 1
Month 9
Year 07
Hour 01
Minuts 55 ----> +60 seconds, no more 54.. its 55 now
Seconds 17

______________________________

I think do that...

PHP Code:
<?PHP
$more_seconds 
60;

$date date("d");
$month date("m");
$year date("y");
$hours date("H");
$minuts =  date("i");
$seconds date("s");

echo 
"day: $date, month: $month, year: $year, Hour: $hours:$minuts:$seconds";

$seconds $seconds $more_seconds;

while(
$seconds 60){
$seconds $seconds 60;
$minuts $minuts 1;
}

while(
$minuts 60){
$minuts $minuts 60;
$hours $hours 1;
}

while(
$hours 24){
$hours $hours 24;
$date $date 1;
}

$ok false;
while(
$ok == false){

if (
$month == OR $month == OR $month == OR $month == OR $month == OR $month == 10 OR $mont == 12){
if (
$date 31){
$date $date 31;
$month $month 1;
}
else
{
$ok true;
}

}
if (
$month == OR $month == OR $month == OR $month == 11){
if (
$date 30){
$date $date 30;
$month $month 1;
}
else
{
$ok true;
}

}

if (
$month == 02){
if (
$date 28){
$date $date 28;
$month $month 1;
}
else
{
$ok true;
}

}

if (
$month 12){
$month $month 12;
$year $year 1;
}

//end $ok == false

echo "day: $date, month: $month, year: $year, Hour: $hours:$minuts:$seconds";

?>
But that script i make... i think have a error... "leap year years" in spanish "aņos biciestos"... anything can help me?

Last edited by Nuker; 09-02-2007 at 01:44 PM.
Reply With Quote