Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Yup, microseconds. You are correct, sir. I will endeavor to more closely RTFM.

What use are you putting the result to?

What I'm doing is simulating a browser transaction and one of the required parameters is epoch time in milliseconds. I don't actually need the result to be millisecond accurate. I just need to pass a 13-digit number with no decimals as one of the parameters in the request. While millisecond accuracy would be nice, all I really need is for the number to be the right number of digits and for the value to be accurate to within a minute or two.

Why not use the scalar context floating point result instead of a nasty string concatenation that will fail in nasty ways about 1/10th of the time?

Ah! I think I get it:

use Time::HiRes qw(gettimeofday); my $timestamp = int (gettimeofday * 1000); print STDOUT "timestamp = $timestamp\n"; exit; Output: timestamp = 1227593060768
One line, no sprintf, and it's definitely a number so a potential future s/printf won't choke.

-Logan
"What do I want? I'm an American. I want more."


In reply to Re^2: Epoch time in milliseconds: Is there a better way? by logan
in thread Epoch time in milliseconds: Is there a better way? by logan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-23 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found