I am using time() in Linux system to get current epoch. most of the cases, it gives correct epoch. but 3/4 times in every hour, it gives the epoch which is ahead of the current time.
have a look at my function,
sub fetch_time
{
Other variables declarations ...
my($cur_ts); <-- variable in which I am going to receive the epoch
Other variables declarations ...
# get the current timestamp
$cur_ts = time(); <-- fetching current epoch
print "$cur_ts;\n";
Other operations ...
}
Samples
sample 1:
system epoch - 1234867548
epoch printed - 1234871946
sample 2:
system epoch - 1234868856
epoch printed - 1234873254
sample 3:
system epoch - 1234928039
epoch printed - 1234932437
Note:
All the time, the difference coming in the range 4000 and above.
What may be the cause for this problem?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.