[SGVLUG] timediff - c++ version - command line program
Matthew Campbell
dvdmatt at gmail.com
Thu Sep 15 21:22:34 PDT 2016
Nice. The same thing's there in Perl and most other languages (turns
out it's a common problem).
Matt
---------
Matthew Campbell
Storage and Cloud Strategy
Office of the CTO
Kaiser Permanente
99 S. Oakland
Pasadena, CA 91101
626-564-7228 (office)
8-338-7228 (tie-line)
818-314-9897 (mobile phone)
Green Center 3-North, 031W29
---------
kp.org/thrive
On Thu, Sep 15, 2016 at 12:31 PM, Sean O'Donnell <sean at seanodonnell.com> wrote:
> Typical PHP copy/paste blunder. *shame!!* lol
>
> Should have been:
>
> print_r($d1->diff($d2));
>
>
>
> On 09/15/2016 12:28 PM, Sean O'Donnell wrote:
>> Nice!
>>
>> In PHP (not sure about python or perl on this method), you can use the
>> DateTime object.
>>
>> Example:
>>
>> #!/usr/bin/env php
>> <?php
>> $d1 = new DateTime('2000-01-01');
>> $d2 = new DateTime('2016-09-09');
>> print $d1->diff($d2)->days;
>> ?>
>>
>> It's also nice for revealing other information about the date difference.
>>
>> Example:
>>
>> print_r($d1->diff($d2)->days);
>>
>>
>> Outputs:
>>
>> DateInterval Object
>> (
>> [y] => 16
>> [m] => 8
>> [d] => 8
>> [h] => 0
>> [i] => 0
>> [s] => 0
>> [invert] => 0
>> [days] => 6096
>> )
>>
>>
>> Just thought to mention in case it was useful for some (other) poor
>> unfortunate php geek.
>>
>> -Sean
>>
>>
>> On 09/09/2016 12:58 AM, mrflash818 at geophile.net wrote:
>>> During the after-party, there was a small interest in using timediff, a
>>> command-line program
>>> for calculating the number of dates between two yyyy-mm-dd dates, that
>>> includes Leap Year/Gregorian Calendar as part of its internal algorithm.
>>>
>>> For the few folks that I talked about it to, the program I wrote is GPL,
>>> and the source code is at:
>>>
>>> http://mrflash818.geophile.net/software/timediff/
>>>
>>> You will need to have the c++ boost libraries installed, to compile it.
>>>
>>> robert at pip2:~/projects/cplusplus/timediff$ ./timediff 2000-01-01 2016-09-09
>>> 6096
>>>
>>>
>>>
>>> Robert
>>> mrflash818
>>>
>>>
>>>
>>>
>>
>>
>
>
More information about the SGVLUG
mailing list