![]() |
C - Entwicklung Bibliotheks-Funktionen: Datum und Zeit lesen Homepage von PS-Trainer - C-Entwicklung - Datum & Zeit - an PS-Trainer |
|
| Date and Time Management | |
| time | Gets the system time. |
| _ftime , structure _timeb | Gets the current time. |
| _strtime, _wstrtime | Copy the time to a buffer. |
| _strdate, _wstrdate | Copy a date to a buffer. |
| time Gets the system time. time_t time( time_t *timer );
Remarks The time function returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock. The return value is stored in the location given by timer. This parameter may be NULL, in which case the return value is not stored. Subject: Time Management Routines Keywords: See also asctime, _ftime, gmtime, localtime, _utime |
||||||
| Return Value time returns the time in elapsed seconds. There is no error return. Parameter
|
||||||
|
Example #include <time.h> void main() /* Set time zone from TZ environment
variable. If TZ is not set, /* Display operating system-style
date and time. */ /* Get UNIX-style time and
display as number and string. */ /* Display UTC. */ /* Convert to time structure
and adjust for PM if necessary. */ /* Note how pointer addition
is used to skip the first 11 /* Print additional time information.
*/ /* Make time for noon on Christmas,
1993. */ /* Use time structure to build
a customized time string. */ /* Use strftime to build a
customized time string. */ Output Today is Tuesday, day 03 of May in the year 1994. |
| _ftime Gets the current time. void _ftime( struct _timeb *timeptr );
Remarks The _ftime function gets the current local time and stores it in the structure pointed to by timeptr. The _timeb structure is defined in SYS\TIMEB.H. It contains four fields:
Subject: Time Management Routines Keywords: See also asctime, ctime, gmtime, localtime, time |
||||||||||||||
| Return Value _ftime does not return a value, but fills in the fields of the structure pointed to by timeptr. Parameter
|
||||||||||||||
|
Example #include <stdio.h> void main( void ) _ftime( &timebuffer ); printf( "The time is
%.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20]
); |
| _strtime, _wstrtime Copy the time to a buffer. char *_strtime( char *timestr ); wchar_t *_wstrtime( wchar_t *timestr );
Remarks The _strtime function copies the current local time into the buffer pointed to by timestr. The time is formatted as hh:mm:ss where hh is two digits representing the hour in 24-hour notation, mm is two digits representing the minutes past the hour, and ss is two digits representing seconds. For example, the string 18:23:44 represents 23 minutes and 44 seconds past 6 P.M. The buffer must be at least 9 bytes long. _wstrtime is a wide-character version of _strtime; the argument and return value of _wstrtime are wide-character strings. These functions behave identically otherwise. Generic-Text Routine Mappings
Subject: Time Management Routines Keywords: See also asctime, ctime, gmtime, localtime, mktime, time, _tzset |
|||||||||||||||||||||
| Return Value Each of these functions returns a pointer to the resulting character string timestr. Parameter
|
|||||||||||||||||||||
|
Example #include <time.h> void main( void ) |
| _strdate,
_wstrdate Copy a date to a buffer. char *_strdate( char *datestr ); wchar_t *_wstrdate( wchar_t *datestr );
Remarks The _strdate function copies a date to the buffer pointed to by datestr, formatted mm/dd/yy, where mm is two digits representing the month, dd is two digits representing the day, and yy is the last two digits of the year. For example, the string 12/05/99 represents December 5, 1999. The buffer must be at least 9 bytes long. _wstrdate is a wide-character version of _strdate; the argument and return value of _wstrdate are wide-character strings. These functions behave identically otherwise. Generic-Text Routine Mappings
Subject: Time Management RoutinesTime Management Routines Keywords: See also asctime, ctime, gmtime, localtime, mktime, time, _tzset |
|||||||||||||||||||||
| Return Value Each of these functions returns a pointer to the resulting character string datestr. Parameter
|
|||||||||||||||||||||
|
Example #include <time.h> void main() /* Set time zone from TZ environment
variable. If TZ is not set, /* Display operating system-style
date and time. */ /* Get UNIX-style time and
display as number and string. */ /* Display UTC. */ /* Convert to time structure
and adjust for PM if necessary. */ /* Note how pointer addition
is used to skip the first 11 /* Print additional time information.
*/ /* Make time for noon on Christmas,
1993. */ /* Use time structure to build
a customized time string. */ /* Use strftime to build a
customized time string. */ Output Today is Tuesday, day 03 of May in the year 1994. |
| Aktuelle Daten dieser Seite | Letzte Änderung: |
| |