By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,252 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,252 IT Pros & Developers. It's quick & easy.

PERL: How to get current time to the Millisecond resolution

P: 4
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
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
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

P: 36
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
Expert 2.5K+
P: 4,059
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
Expert Mod 2.5K+
P: 3,503
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.