_dos_gettime, _dos_settime
Gets and sets system time.
Defined in header <dos.h>
Syntax
#include <dos.h>
void _dos_gettime(struct dostime_t *timep);
unsigned _dos_settime(struct dostime_t *timeip);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ |
Remarks
_dos_gettime fills in the clostime_t structure pointed to by timep with the system's current time.
_dos_settime sets the system time to the values in the dostime_t structure pointed to by timep.
The dostime_t structure is defined as follows:
struct dostime_t {
| unsigned char hour; | /* hours 0-23 */ |
unsigned char minute; /* minutes 0-59 */ unsigned char second; /* seconds 0-59 */ unsigned char hsecond; /* hundredths of seconds 0-99 */ };
Return value
_dos_gettime does not return a value.
If _dos_settime is successful, it returns 0. Otherwise, it returns the DOS error code, and the global variable errno is set to the following:
EINVAL Invalid time
See also
Example
#include <stdio.h>
#include <dos.h>
int main (void) /* Example for _dos_gettime. */
{
struct dostime_t t;
_dos_gettime(&t) ;
printfC'The current time is: %2d:%02d:l02d.%02d\n", t.hour, t.minute,
t.second, t.hsecond);
return 0;
#include <dos.h>
#include <process.h>
#include <stdio.h>
int main (void) /* Example for _dos_settime. */
{
struct dostime_t reset;
reset.hour = 17;
reset.minute =
reset.second = 0;
reset.hsecond =
printf( "Setting time to 5 PM.\n"l
_dos_settime(&reset) ;
system ("time");
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `_dos_gettinne, _clos_settinne` read as `_dos_gettime, _dos_settime`
Stable link: /3.1/dos.h/_dos_gettime/
· short form /3.1/_dos_gettime/