Re: subtract 1 day



"meltedown" <groups2@xxxxxxxxxx> wrote in message
news:Gt5Yf.202883$G_2.26129@xxxxxxxxxxxxxxxxxxxxxxxxx
Andy Jeffries wrote:
On Mon, 03 Apr 2006 08:06:55 +0000, meltedown wrote:
I can't see what I'm doing wrong. I'm subtracting 60*60*24 from a unix
time stamp and the result is 23 hours earlier, not 24. Start with a unix
time stamp:

Try doing this instead:

$unixtime2 = strtotime("-1 day", $unixtime);

I couldn't see what you were doing wrong in your code from a quick
glance,
but the above way is easier to read anyway.

Cheers,


Andy

Thanks that really helped a lot, five minutes to fix what I've been
banging my head against all night. Funny thing is that code worked fine
for a year and it still works for most dates but it hit that one date and
didn't work right.

I had the same effect when clocks were turned +1 hour to daylight saving
time on March 26th here in Finland. I had two dates of which one was in
normal time and another that was in daylight saving time and I kept
wondering why the difference between them is was 5 days and 23 hours or
something like that, until the whole daylight saving thing finally dawned to
me. I fixed it by using GMT times which are not affected by DST.

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
spam@xxxxxxxxxxxxx | Gedoon-S @ IRCnet | rot13(xvzzb@xxxxxxxxxxxxx)


.



Relevant Pages

  • Storing Date/Time with Daylight savings
    ... it will have a Time Stamp column and other columns to save real ... saved in the Time Stamp; I can use either System Time or Local Time; ... Local Time, I can have problems with Daylight saving. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: suppress carriage return..
    ... It will convert from DOS to Unix format, or vice versa, using ... One feature I like about it is that it does not change ... the time stamp on the file. ...
    (comp.lang.fortran)
  • Re: Mount My Creation
    ... | while UNIX (beware of unresearched, wide-sweeping generalizations...) ... | provides one the "Last modified" date and time stamp? ...
    (freebsd-questions)
  • Modifying a files time stamp
    ... Is there a Perl (core or mod) equivalent to the UNIX 'touch' command? ... need to change the time stamp of a file without changing its contents. ...
    (comp.lang.perl)
  • Re: subtract 1 day
    ... Andy Jeffries wrote: ... time stamp and the result is 23 hours earlier, ... Start with a unix ... Funny thing is that code worked fine for a year and it still works for most dates but it hit that one date and didn't work right. ...
    (comp.lang.php)