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

Hello,

does anyboady knows how to produce a "64 bit timestamp" with perl?

It looks like this: ceaeaa69.c09331a0

This is for Wed, Nov 18 2009 18:16:25.752 normally.

This is the timestamp format you get when you ask an ntp server with ntpdate.

Thanks in advance.

Replies are listed 'Best First'.
Re: 64 bit timestamp
by ikegami (Patriarch) on Nov 18, 2009 at 20:25 UTC

    Left of the "." is the number of seconds since Jan 1st, 1900 UTC.

    Right of the "." is the number of 1/(2**32)th of seconds.

    use Time::HiRes qw( time ); # Number of secs between 1900/01/01 UTC and 1970/01/01 UTC. my $ntp_epoch_diff = 2208988800; my $time = time(); my $ntp_ts = sprintf('%08X.%08X', int($time) + $ntp_epoch_diff, ($time - int($time)) * (2**32), );

    (I don't know if the number of secs is correct.)

      Thank you very much! Just what I wanted =)
Re: 64 bit timestamp
by BrowserUk (Patriarch) on Nov 18, 2009 at 20:03 UTC

    When you say

    produce a "64 bit timestamp"

    do you mean, get the current time as a 64-bit value? (In hex?).

    Or convert a timestamp (as say produced by time) into a 64-bit value?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.