Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date manipulations for a newbie

Status
Not open for further replies.

dajo

IS-IT--Management
Jan 13, 2001
27
US
When I use

my $datevar = timelocal(0,53,17,22,7,53);

everything is fine.

When I use

my $datevar = timelocal(0,53,17,22,7,51);

I get the 500 Internal Server error.

What am I doing wrong? Do I need to use Date::Manip?

Thanks


 
When I tried running timelocal(which, at least in Perl 5.005_03, requires "use Time::Local") with the same parameters as you, using a year of 51 and 53, both returned a timestamp of -1, indicating an illegal date - either before 1/1/1970, or after ?/?/2038.

I don't know why using 51 you don't get the 'Internal Error', but using 53 you do - it's irrelevant since in either case the return value you get is a -1 anyway. I have used Date::Manip, but not in a long time - I remember it being a very full featured date/time conversion program, but I can't confirm whether or not it would do what you're looking for, although I'd be surprised if it didn't.

One thing I remember about Date::Manip is that it can do nearly any date conversion you can think of, but it was admittedly(by the author) slow - again, this may have changed since I used it last. It would be fine for converting a small number of dates, but if you had to convert thousands or more dates, you might want to look for a faster alternative.

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Thanks for answering. Actually, I had read about the "since 1970" part, but it worked for dd/mm/1953 so I forgot, and was curious as to why it wouldn't work for 1951.

Date::Manip will be fine for me since I only need to calculate maybe six or seven date values in the entire program. Of course, if the site is hit heavily there may be many instances of the program running at any given time, but each program instance will only involve a few manipulations so it will probably be fine.

There's always DATE::CALC, etc...

At least now I understand why it doesn't work.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top