Getting the current time

You use the TClock::Now member function to get the current time on a clock. To read the time on a clock, you:

  1. Instantiate a class derived from TTime and a class derived from TClock.
    The time class receives the current time value of the clock.
  2. Call the clock's Now function to get the current time on the clock.
    Now puts the current time value into the TTime instance.
To get the current time on the system clock in seconds:

      TSeconds    currentTime;
      TSystemClock    realTimeClock;
      realTimeClock.Now(currentTime);
To get the current UTC time:

      TSeconds    currentTime;
      TDateTimeClock  UTCTimeClock;
      UTCTimeClock.Now(currentTime);
You typically convert the UTC time to local time using the international utilities (see Text, Native Language Support, and Time Media for more information).


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker