homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

Perl date limits -and- how to get milliseconds?
Two questions, perl date and how to get time in milliseconds?

 11:47 pm on Dec 2, 2010 (gmt 0)

Hi webmasters, instead of opening two threads, two questions here.

1. Should I worry on the limits of date (year) in Perl? I know Perl has its own y2k sort of limit on 2039 I think. I read about it and it was mentioned that we should not worry if the admins update the core whatever from 32 bits to 64 and perhaps newer versions of perl would eliminate this problem. Any ideas?

2. How do you get milliseconds in Perl? I can only get time down to seconds. I'm working on my latest CMS putting some new features I find very useful, but for several reasons including measuring how much time it takes to generate some simple and complex pages I would like to include on the page "this page was generated in XX milliseconds... or seconds". I like to go simple and fast but some procedures require tweaking.




 1:44 am on Dec 3, 2010 (gmt 0)

Got the ms:

sub ms{
($s, $usec) = gettimeofday();
return $seg;

From there is only a matter of getting the ms at the beginning of the operation and then again at the end, then just do the math between the two and there you go.

As for the date (years) limit in perl I'm still wondering what's the best metod or just sticking to localtime.


 9:00 am on Dec 3, 2010 (gmt 0)

or you could use Benchmark.pm:
http://search.cpan.org/~jesse/perl-5.12.2/lib/Benchmark.pm [search.cpan.org]

this should address your first question.
Does Perl have a Year 2000 or 2038 problem? Is Perl Y2K compliant?:
http://perldoc.perl.org/perlfaq4.html#Does-Perl-have-a-Year-2000-or-2038-problem%3f-Is-Perl-Y2K-compliant%3f [perldoc.perl.org]


 8:22 pm on Dec 7, 2010 (gmt 0)

Perl 5.12 has 64-bit time on 32-bit systems too. If you have older Perl, you can use DateTime CPAN module.

For milliseconds use Time::HiRes.


 12:32 am on Dec 8, 2010 (gmt 0)

re: Time::HiRes module & Benchmark.pm:
http://search.cpan.org/~jesse/perl-5.12.2/lib/Benchmark.pm#:hireswallclock [search.cpan.org]


 4:29 am on Dec 13, 2010 (gmt 0)

Glad to know Perl 5.12 has 64 bit time.

Thanks for the help, now i have more clear what to do.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved