in reply to question about unix timestamps (epoch)

If you want to do it that way, you can just use int:
#!/usr/bin/perl -w my $_timestamp1 = '1189669351'; my $_timestamp2 = '1189395751'; my $_timebetween = $_timestamp1 - $_timestamp2; print int($_timebetween/(60*60*24));

Replies are listed 'Best First'.
Re^2: question about unix timestamps (epoch)
by ikegami (Patriarch) on Sep 13, 2007 at 13:34 UTC

    It won't always give the right answer, because not all days are 24*60*60 seconds long. It's possible for your code to return one more day or one less day than expected.

    For example,
    it's possible for 4:30am one day to 4:00am the next day to return 1, and
    it's possible for 4:00am one day to 4:30am the next day to return 0.

      That's a good point. I was just about to ask why when I realised the obvious! I guess the solution I gave, was more "the number of 24 hour periods". Still, that should work in most cases, I guess it depends how critical it is.