Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17598

Re: Days until Christmas

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" <cmbecker69@arcor.de>
Newsgroups comp.lang.php
Subject Re: Days until Christmas
Date Fri, 27 Oct 2017 01:38:40 +0200
Organization solani.org
Lines 31
Message-ID <ostrlr$6i5$1@solani.org> (permalink)
References <osi15t$14b7$2@gioia.aioe.org> <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> <ost629$o1b$1@solani.org> <6KtIB.155563$J83.116459@fx06.iad>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1509061115 6725 eJwFwYEBwEAEA8CVaAjWwdt/hN45qJwwOs3Pb1ZFWIjCmmyJwwqwluQtNKZ9szrv3kt+PwB/EIQ= (26 Oct 2017 23:38:35 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Thu, 26 Oct 2017 23:38:35 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0
Content-Language de-DE
Cancel-Lock sha1:i6Hter7mkoEw1pqJKfUPG26/Rw0=
X-User-ID eJwFwQEBwDAIAzBNbLSAnA6OfwlPcGnscIKOxcbhCM+00pTvo32KZhks049GOVGde3nU8QMuHBGZ
X-NNTP-Posting-Host eJwFwQkBACAIBLBKIHBgHPn6R3AzAaNcYVBbWwSlUPtcQp43h1gCzTRzc0s1xlXUZ60L/j4RcxEF
In-Reply-To <6KtIB.155563$J83.116459@fx06.iad>
Xref csiph.com comp.lang.php:17598

Show key headers only | View raw


On 27.10.2017 at 00:56, Mark Lloyd wrote:

> On 10/26/2017 12:29 PM, Christoph M. Becker wrote:
>
>> 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.
> 
> I've tried this and it seems to be working OK. I may be able to use it
> except I prefer a result that is more precise than days.
> 
> One odd thing is that when I looked at the PHP documentation for
> DateTime -> format, it says it uses the same parameters as the "date"
> function, these DO NOT use % signs. 'a' itself shows am or pm. Where did
> you get %a for DateTime -> format?

DateTime::diff(DateTime) returns a DateInterval (not a DateTime) object,
and its ::format() method expects a somewhat different format[1].  If
you want more detailed information, you can use something like this:

 ->format('%a days, %h hours, %i minutes and %s seconds …')

[1] <http://www.php.net/manual/en/dateinterval.format.php>

-- 
Christoph M. Becker

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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