469,289 Members | 2,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

PERL: How to get current time to the Millisecond resolution

Dear All,

I am using Perl version v5.8.2 built for IBM AIX. I want to get the current time till the resolution of milliseconds. Now I am able to get till seconds using localtime function.

Can anybody help me in getting the time till milliseconds?

Many Many Thanks in advance.
Feb 5 '08 #1
4 14547
KevinADC
4,059 Expert 2GB
Dear All,

I am using Perl version v5.8.2 built for IBM AIX. I want to get the current time till the resolution of milliseconds. Now I am able to get till seconds using localtime function.

Can anybody help me in getting the time till milliseconds?

Many Many Thanks in advance.
Look into Time::HiRes
Feb 5 '08 #2
Expand|Select|Wrap|Line Numbers
  1. my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
  2.     my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
  3.     my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings);
  4.     ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
  5.  
  6.     my $year;
  7.     my $theTime;
  8.  
  9.     $year = 1900 + $yearOffset;
  10.     $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$month] $dayOfMonth, $year";

-- shafi
Feb 6 '08 #3
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
  2.     my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
  3.     my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings);
  4.     ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
  5.  
  6.     my $year;
  7.     my $theTime;
  8.  
  9.     $year = 1900 + $yearOffset;
  10.     $theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$month] $dayOfMonth, $year";

-- shafi
Guess you didn't read the question shafi:

How to get current time to the Millisecond resolution
Feb 6 '08 #4
numberwhun
3,503 Expert Mod 2GB
Guess you didn't read the question shafi:
Yet another case for RTFA!
Feb 6 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Uwe Mayer | last post: by
2 posts views Thread by Kevin Horton | last post: by
10 posts views Thread by Partho Choudhury | last post: by
1 post views Thread by Valéry Bezençon | last post: by
reply views Thread by Kirt Loki Dankmyer | last post: by
3 posts views Thread by cj | last post: by
9 posts views Thread by Ron Adam | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.