Command to get time in milliseconds

后端 未结 12 968
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 04:01

Is there a shell command in Linux to get the time in milliseconds?

12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 04:19

    Perl can be used for this, even on exotic platforms like AIX. Example:

    #!/usr/bin/perl -w
    
    use strict;
    use Time::HiRes qw(gettimeofday);
    
    my ($t_sec, $usec) = gettimeofday ();
    my $msec= int ($usec/1000);
    
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
        localtime ($t_sec);
    
    printf "%04d-%02d-%02d %02d:%02d:%02d %03d\n",
        1900+$year, 1+$mon, $mday, $hour, $min, $sec, $msec;
    

提交回复
热议问题