-2

I have a small code as part of a huge file as follows:

if(($lastLogTime + $logOffset)>= $text1)
{
    echo $text1.'<br>';

    $uptime=$uptime + (($text1 - $lastLogTime)/60000);
    echo ($text1 - $lastLogTime).'<br>';
    fwrite($fd, $uptime.',');
    echo $uptime.'<br><br>';

    $lastLogTime = ($lastLogTime + 1800000);
    echo $lastLogTime.' ME <br>';
}

The weird part is the output for the final $lastLogTime is NOT getting added by the 1800000 OR a variable called $logInterval = 1800000 which was initialized earlier.

The output is

1298083876650     -  i.e lastLogtime
1298083877661     - text1

1011              - the difference
0.01685           - uptime

1298085676650 ME  - damn ! doesn't get added by 1800000

NEW EDIT :

I solved it ! bad answers guys.. Thanks for the time anyways.

Am i the only one facing weird shhit like this ?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Zac
  • 695
  • 1
  • 11
  • 34

1 Answers1

0

I suspect it has something to do with this: What's the maximum size for an int in PHP?

Check out the php date function. Though working with dates can be tedious, converting everything to seconds normally isn't the best approach.

http://php.net/manual/en/function.date.php

Community
  • 1
  • 1
Ryre
  • 6,135
  • 5
  • 30
  • 47
  • AS is said, it's a huge file and timestamps MORE than 1298085676650 + 1800000 ARE getting displayed later after the loop execution !! – Zac Mar 20 '11 at 01:24
  • COuld you gimme a code that achieves this in a different way? – Zac Mar 20 '11 at 01:25
  • Use date, then strtotime for comparisons. Here's a decent explanation: http://www.highlystructured.com/comparing_dates_php.html – Ryre Mar 20 '11 at 01:49