Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.php Subject: Days until Christmas (was: its quiet here - test) Date: Thu, 26 Oct 2017 19:29:49 +0200 Organization: solani.org Lines: 35 Message-ID: References: <59eef5e9$0$797$e4fe514c@news.xs4all.nl> <59f1b002$0$818$e4fe514c@news.xs4all.nl> <7zoIB.22653$463.8426@fx13.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1509038985 24619 eJwFwYEBwCAIA7CXxJWC5wiV/09Y4h+NHaATPj6aOorpZdQxASHeiaXOYj69rtiZc6GNh/oBOjoSMw== (26 Oct 2017 17:29:45 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 26 Oct 2017 17:29:45 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 X-NNTP-Posting-Host: eJwFwYEBwDAEBMCVEP9inCL2H6F3OFR2OEHHYmdksj6nGPrwdYBbomXXQic8gVS8K16qkj8Y6xA8 In-Reply-To: <7zoIB.22653$463.8426@fx13.iad> X-User-ID: eJwFwYkBwCAIA8CVDE8s44gl+4/gXTrBu4PJSKVkBc3iUR1C8Nv4vDydv9uOWT1s7UDjlMUDGp0QzA== Cancel-Lock: sha1:TR2tHc+2JjR/qx1ufObu7P3ywco= Content-Language: de-DE Xref: csiph.com comp.lang.php:17594 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