Class::Date

  • Thread starter Alexandre Jaquet
  • Start date
A

Alexandre Jaquet

Anyone know how I can get millisecond I can't find in documentation.

I've try

#!/usr/bin/perl -w
use strict;
use Class::Date qw:)errors date localdate gmdate now);

my $date_start = getTime ();

sub getTime {

my $date = new Class::Date (now);
$Class::Date::DATE_FORMAT="%H%M%S";
warn "date hour test -->".$date;
return $date;
}
 
J

jamie

Anyone know how I can get millisecond I can't find in documentation.
I've try

#!/usr/bin/perl -w
use strict;
use Class::Date qw:)errors date localdate gmdate now);

my $date_start = getTime ();

sub getTime {

my $date = new Class::Date (now);
$Class::Date::DATE_FORMAT="%H%M%S";
warn "date hour test -->".$date;
return $date;

Sorry for not quoting the OP...It's my first time using a computer...
:-D

More precisely http://datetime.perl.org/faq.html
 
J

jamie

Anyone know how I can get millisecond I can't find in documentation.
#!/usr/bin/perl -w
use strict;
use Class::Date qw:)errors date localdate gmdate now);
my $date_start = getTime ();
sub getTime {
my $date = new Class::Date (now);
$Class::Date::DATE_FORMAT="%H%M%S";
warn "date hour test -->".$date;
return $date
;

Sorry for not quoting the OP...It's my first time using a computer...
:-D

More precisely http://datetime.perl.org/faq.html

You will find this also helpful....
http://search.cpan.org/dist/Time-HiRes/HiRes.pm

Jamie
 
J

jamie

i didn't find something usefull with HiRes :(
Perhaps I am misunderstanding what you are trying to accomplish. If,
for example, you needed to time how long something takes...in
milliseconds...you could:

#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw(gettimeofday);

$t0 = gettimeofday();
#Do something here
$t1 = gettimeofday();
$elapsed = $t1 - $t0;

<disclaimer> Stolen from "The Cookbook"</disclaimer>
 
A

Alexandre Jaquet

(e-mail address removed) a écrit :
Perhaps I am misunderstanding what you are trying to accomplish. If,
for example, you needed to time how long something takes...in
milliseconds...you could:

#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes qw(gettimeofday);

$t0 = gettimeofday();
#Do something here
$t1 = gettimeofday();
$elapsed = $t1 - $t0;

<disclaimer> Stolen from "The Cookbook"</disclaimer>

Great Jamie it was exactly what I was looking for thx :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top