timestamp with milisecond
timestamp with milisecond
am 03.06.2011 09:38:44 von Anirban Adhikary
Hi List
Is it possible to get the current time_stamp with milisecond format
like HH:MI:SS:NNN DD:MM:YYYY(NNN is the milisecond)
If yes then how can I achieve the same..............
Thanks & Regards in advance
Anirban Adhikary.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: timestamp with milisecond
am 03.06.2011 09:40:18 von Rob Coops
--001636831fa8b0791404a4c9de91
Content-Type: text/plain; charset=UTF-8
On Fri, Jun 3, 2011 at 9:38 AM, Anirban Adhikary
> wrote:
> Hi List
> Is it possible to get the current time_stamp with milisecond format
>
> like HH:MI:SS:NNN DD:MM:YYYY(NNN is the milisecond)
>
> If yes then how can I achieve the same..............
>
> Thanks & Regards in advance
> Anirban Adhikary.
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>
Hi Anirban,
Sure you can have a look at the following CPAN module:
http://search.cpan.org/dist/Time-HiRes/HiRes.pm
It will do exactly what you are looking for.
Regards,
Rob
--001636831fa8b0791404a4c9de91--
Re: timestamp with milisecond
am 03.06.2011 13:42:38 von Gurpreet Singh
Me too a beginner, posting a reply in childish speech:
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Time::HiRes qw(gettimeofday);
5 use Time::Local;
6 use Time::localtime;
7
8 my $t0 = gettimeofday;
9
10 my $forlocaltime = int($t0);
11 my $for_millisecond = int(($t0-$forlocaltime)*1000);
12
13
14 my $tm = localtime($forlocaltime);
15
16 printf ("Current Time- %02d:%02d:%02d:%03d %02d/%02d/%02d\n", $tm->hour, $tm ->min,$tm->sec,$for_millisecond, $tm->mday, $tm->mon+1, $tm->year+1900);
Output -
Current Time- 17:09:04:312 03/06/2011
Current Time- 17:09:08:140 03/06/2011
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: timestamp with milisecond
am 03.06.2011 13:46:29 von Gurpreet Singh
Posting in some childish perl........please bear it
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Time::HiRes qw(gettimeofday);
5 use Time::Local;
6 use Time::localtime;
7
8 my $t0 = gettimeofday;
9
10 my $forlocaltime = int($t0);
11 my $for_millisecond = int(($t0-$forlocaltime)*1000);
12
13 my $tm = localtime($forlocaltime);
14
15 printf ("Current Time- %02d:%02d:%02d:%03d %02d/%02d/%02d\n", $tm->hour, $tm ->min,$tm->sec,$for_millisecond, $tm->mday, $tm->mon+1, $tm->year+1900);
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: timestamp with milisecond
am 04.06.2011 01:47:53 von Uri Guttman
>>>>> "GS" == Gurpreet Singh writes:
GS> Posting in some childish perl........please bear it
please don't post with line numbers. that makes it very hard to
cut/paste your code to try it out.
GS> 1 #!/usr/bin/perl
GS> 2 use warnings;
GS> 3 use strict;
GS> 4 use Time::HiRes qw(gettimeofday);
GS> 5 use Time::Local;
GS> 6 use Time::localtime;
GS> 7
GS> 8 my $t0 = gettimeofday;
GS> 9
GS> 10 my $forlocaltime = int($t0);
GS> 11 my $for_millisecond = int(($t0-$forlocaltime)*1000);
GS> 12
GS> 13 my $tm = localtime($forlocaltime);
GS> 14
GS> 15 printf ("Current Time- %02d:%02d:%02d:%03d %02d/%02d/%02d\n", $tm->hour, $tm ->min,$tm->sec,$for_millisecond, $tm->mday, $tm->mon+1, $tm->year+1900);
regardless of the need for millisecond info, use the POSIX::strftime
function as it does all of that formatting timestamps for you. and since
you pass it a string you can just interpolate the millisecond part into
that string.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: timestamp with milisecond
am 04.06.2011 05:40:14 von Peter Scott
On Fri, 03 Jun 2011 19:47:53 -0400, Uri Guttman wrote:
> regardless of the need for millisecond info, use the POSIX::strftime
> function as it does all of that formatting timestamps for you. and sinc=
e
> you pass it a string you can just interpolate the millisecond part into
> that string.
Like so:
$ perl -MPOSIX=3Dstrftime -MTime::HiRes=3Dtime -le '$t =3D time; $s=3Dspr=
intf "%
06.3f", $t-int($t/60)*60; print strftime "%H:%M:$s %d:%m:%Y", localtime=20
$t'
20:38:44.551 03:06:2011
--=20
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=3D0137001274
http://www.oreillyschool.com/courses/perl3/
--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/