Dany has asked for the wisdom of the Perl Monks concerning the following question:

Hello: I like use for a name of a file the next format: - LVK"yyyymmddhhmmss(msmsmsms)".dat Where (ms...) is for miliseconds, but i don't knock any function that return the milisecons for a localtime. It is possible Thanks

Replies are listed 'Best First'.
Re: MilliSeconds
by rob_au (Abbot) on Jun 11, 2002 at 10:47 UTC
    You can retrieve date and time information with high precision via the Time::HiRes module. The module documentation includes a number of examples of use.

    The code which you end up using might look something like the following ...

    use Time::HiRes qw/ time /; my $u_sec = time; my @date = localtime($u_sec); my $format = sprintf( "%4d%02d%02d%02d%02d%02d(%06d)", $date[5] + 1900, $date[4] + 1, $date[3], $date[2], $date[1], $date[0], substr($u_sec, index($u_sec, '.') + 1) ); print $format, "\n";

     

      Ok, the date appears in correct format. But not appear the miliseconds in the format. Appear the next message: 20020611151959(1023801599) Thanks.