[SGVLUG] timediff - c++ version - command line program

Sean O'Donnell sean at seanodonnell.com
Thu Sep 15 12:28:53 PDT 2016


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