| Mac OS X header: | CoreServices/CoreServices.h |
| Mac OS 9 header: | DateTimeUtils.h |
| Getting the Current Date and Time Functions | |
| GetDateTime | Obtains the current date-time information, expressed as the number of seconds elapsed since midnight, January 1, 1904. |
| GetTime | Obtains the current date-time information, expressed as a date and time. |
| ReadDateTime | Copies the date-time information from the clock chip into low memory. |
GetDateTime |
| Carbon status: | Supported |
Obtains the current date-time information, expressed as the number of seconds elapsed since midnight, January 1, 1904.
void GetDateTime (
UInt32 *secs
);
On return, the number of seconds elapsed since midnight, January 1, 1904.
The low-memory copy of the date and time information is also accessible through the global variable Time.
If an application disables interrupts for longer than a second, the date-time information returned by the GetDateTime function might not be exact. The GetDateTime function is intended to provide fairly accurate time information, but not scientifically precise data.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
GetTime |
| Carbon status: | Supported |
Obtains the current date-time information, expressed as a date and time.
void GetTime (
DateTimeRec *d
);
On return, the fields of the date-time structure contain the current date and time.
The GetTime function first calls the GetDateTime function to obtain the number of seconds elapsed since midnight, January 1, 1904. It then calls the SecondsToDate function to convert the number of seconds into a date and time.
As an alternative to using the GetTime procedure, you can pass the value of the global variable Time to the
If an application disables interrupts for longer than a second, the date-time information returned by the GetTime function might not be exact. The GetTime function is intended to provide fairly accurate time information, but not scientifically precise data.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
ReadDateTime |
| Carbon status: | Supported |
Copies the date-time information from the clock chip into low memory.
OSErr ReadDateTime (
UInt32 *time
);
On return, the current time expressed as the number of seconds elapsed since midnight, January 1, 1904.
A result code. If the clock chip cannot be read, ReadDateTime returns the clkRdErr result code. The operation might fail if the clock chip is damaged. Otherwise, the function returns the noErr result code.
System software uses this function at startup time. Your application should never need to use this function.
The low-memory copy of the date and time information is accessible through the global variable Time.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2001 Apple Computer, Inc. (Last Updated July 17, 2001)