Get current time

  • Follow


How can we get current time accurate to milli sec in C++/unix?
Is there some API to perform this function?

0
Reply rishi.shah (13) 9/27/2005 10:25:22 PM

Rich Teer <rich.teer@rite-group.com> writes:

> On Tue, 27 Sep 2005, rishi.shah@patni.com wrote:
>
>> How can we get current time accurate to milli sec in C++/unix?
>> Is there some API to perform this function?
>
> Dujno about milliseconds, but gettimeofday will give it to you
> in microseconds, provided your HW and OS support that granularity.

ftime(3) will give you milliseconds.  I can't say I've used it,
though; I always use gettimeofday(2).


-- 
Roger Leigh
                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                Debian GNU/Linux        http://www.debian.org/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
0
Reply Roger 9/27/2005 10:26:30 PM


On Tue, 27 Sep 2005, rishi.shah@patni.com wrote:

> How can we get current time accurate to milli sec in C++/unix?
> Is there some API to perform this function?

Dujno about milliseconds, but gettimeofday will give it to you
in microseconds, provided your HW and OS support that granularity.

HTH,

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
0
Reply Rich 9/27/2005 10:29:38 PM

rishi.shah@patni.com wrote:
> How can we get current time accurate to milli sec in C++/unix?
> Is there some API to perform this function?

gettimeofday()
clock_gettime()

The second one is interesting because you can specify CLOCK_REALTIME (ie 
wallclock) or CLOCK_MONOTONIC (doesn't jump with NTP corrections).

Chris
0
Reply Chris 9/27/2005 10:49:53 PM

3 Replies
200 Views

(page loaded in 0.04 seconds)

Similiar Articles:













7/22/2012 1:55:14 PM


Reply: