CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Date manipulation - dates prior to year 2000 giving probelms ...

 



eagleZ
New User

Jan 4, 2012, 1:49 AM

Post #1 of 3 (1001 views)
Date manipulation - dates prior to year 2000 giving probelms ... Can't Post

I am running perl 5.8.5 on linux and wrote the following script:
#!/usr/bin/perl
use strict;
use warnings;
use Date::Parse;
use Date::Format;
my $start = "11/01/2000";
my $stop = "11/02/2000";
my $diff = str2time($stop) - str2time($start);
printf "diff btw %s and %s is %d secs is = %d days\n", $start, $stop, $diff, $diff/86400;

if i replace the year to any before Y 1963 (e.g. $start="11/01/1962";), the script breaks down.

The script was working before fine. There were some changes the system guys made in my profile and now none of the other users can run it either.

I believe that there is a system change but don't know how to find it.


(This post was edited by eagleZ on Jan 4, 2012, 2:36 AM)


rovf
Veteran

Jan 4, 2012, 7:01 AM

Post #2 of 3 (989 views)
Re: [eagleZ] Date manipulation - dates prior to year 2000 giving probelms ... [In reply to] Can't Post

- Just to clarify: How about 1969? It works or doesn't work?

- I would first verify that indeed str2time returns an incorrect value (if your description of the problem is correct, this should be the case). You can use this page to see which value *should* be returned: http://unixepoch.com/

- If str2time doesn't work, I would just debug it.

- Did you install Date::Parse yourself, or is this done by some admin? I notice that you are using a very old Perl version, so if someone had installed a *new* version of Date::Parse in the meantime, this could cause problems due to incompatibilities.

- Your date specification is ambiguous. Please check the "BUGS" section in the documentation for Date::Parse, whether it applies to your case.


eagleZ
New User

Jan 17, 2012, 8:18 AM

Post #3 of 3 (900 views)
Re: [rovf] Date manipulation - dates prior to year 2000 giving probelms ... [In reply to] Can't Post

Thanks rovf,
the program works with 1969. The answers are correct as well. but as soon as i enter 1962 or previous year. It stops working.

I checked the website for Unix Time conversion. It enhanced my understanding of unix date conversion. Thanks.

str2time I will check.

Kind regards

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives