Home > Archive > PERL Miscellaneous > August 2005 > Calculation with DATEs
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Calculation with DATEs
|
|
| Dietmar Kehr 2005-08-29, 6:59 pm |
|
I need a procedure for calculations with dates,
e.g. let
$date1= 22 June 1960
$date2= 29 August 2004
then i would appreciate a procedure that calculates
the time-difference from $date1 until $date2 and such things.
Are there data-formats for dates and such
procedures? Where do I find them?
Best regards.
| |
| Gunnar Hjalmarsson 2005-08-29, 6:59 pm |
| Dietmar Kehr wrote:
> I need a procedure for calculations with dates,
> e.g. let
> $date1= 22 June 1960
> $date2= 29 August 2004
> then i would appreciate a procedure that calculates
> the time-difference from $date1 until $date2 and such things.
>
> Are there data-formats for dates and such
> procedures?
Yes.
> Where do I find them?
In the part of the docs that describes built-in functions and in CPAN.
Surprise, surprise...
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
| |
| Paul Lalli 2005-08-29, 6:59 pm |
| Dietmar Kehr wrote:
> I need a procedure for calculations with dates,
> e.g. let
> $date1= 22 June 1960
> $date2= 29 August 2004
> then i would appreciate a procedure that calculates
> the time-difference from $date1 until $date2 and such things.
>
> Are there data-formats for dates and such
> procedures? Where do I find them?
>
> Best regards.
Have you bothered to read the FAQ yet?
perldoc -q date
Found in /opt/perl/lib/5.6.1/pod/perlfaq4.pod
How can I compare two dates and find the difference?
Read that, follow the suggestions contained therein, and if you don't
understand or have trouble implementing the results, feel free to try
posting here again.
Paul Lalli
| |
| William James 2005-08-30, 3:56 am |
|
Dietmar Kehr wrote:
> I need a procedure for calculations with dates,
> e.g. let
> $date1= 22 June 1960
> $date2= 29 August 2004
> then i would appreciate a procedure that calculates
> the time-difference from $date1 until $date2 and such things.
Since they won't help you, I'll step in. Use Ruby.
require 'date'
puts Date.new(2004,8,29) - Date.new(1960,6,22)
puts Date.new(1960,6,22) + 16139
puts Date.new(2004,8,29) - Date.new(2004,7,31)
-->
16139
2004-08-29
29
| |
|
|
|
|
|