Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17594
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Days until Christmas (was: its quiet here - test) |
| Date | 2017-10-26 19:29 +0200 |
| Organization | solani.org |
| Message-ID | <ost629$o1b$1@solani.org> (permalink) |
| References | (1 earlier) <ie7HB.22292$wT2.6774@fx22.iad> <59eef5e9$0$797$e4fe514c@news.xs4all.nl> <gLOHB.37370$Ov1.6569@fx30.iad> <59f1b002$0$818$e4fe514c@news.xs4all.nl> <7zoIB.22653$463.8426@fx13.iad> |
On 26.10.2017 at 19:02, Mark Lloyd wrote:
> On 10/26/2017 04:51 AM, Luuk wrote:
>
> [snip]
>
>> LOLm where do you in this '62 days' consider those 25 hours?
>
> Once I have the 2 times in seconds (now and later), I determine is DST
> (Damn Stupid Time, it really makes time calculations more complicated
> for no actual benefit) is active for each of them. This is done using
> the PHP date function; date('I', $time).
>
> If DST is active later but not now, add the DST offset to the interval.
>
> If DST is active now but not later, subtract the DST offset from the
> interval.
>
> "DST offset" is usually 3600 (60*60 for "add 1 hour"), unless you live
> on Lord Howe Island (1800) or Troll Station, Antarctica (7200);
>
> The interval is now ready to be converted to days by dividing by 86400.
That appears to be overly complicated. Wouldn't
(new DateTime('now'))
->diff(new DateTime('2017-12-25T00:00'))
->format('%a days until Christmas')
suffice? Okay, that rounds down, and your solution rounds up, but that
could be catered to.
--
Christoph M. Becker
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
its quiet here - test bill <william@TechServSys.com> - 2017-10-22 07:58 -0400
Re: its quiet here - test hah <hah@no.email.stupid.invalid> - 2017-10-22 15:31 -0500
Re: its quiet here - test Luuk <luuk@invalid.lan> - 2017-10-24 10:12 +0200
Re: its quiet here - test Mark Lloyd <not@mail.invalid> - 2017-10-24 17:01 -0500
Re: its quiet here - test Luuk <luuk@invalid.lan> - 2017-10-26 11:51 +0200
Re: its quiet here - test Mark Lloyd <not@mail.invalid> - 2017-10-26 12:02 -0500
Days until Christmas (was: its quiet here - test) "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-26 19:29 +0200
Re: Days until Christmas Mark Lloyd <not@mail.invalid> - 2017-10-26 17:56 -0500
Re: Days until Christmas "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-10-27 01:38 +0200
Re: Days until Christmas Mark Lloyd <not@mail.invalid> - 2017-10-26 20:48 -0500
csiph-web