函数简介函数原型:
void _ftime(
struct _timeb *timeptr
);
头文件:
<sys/types.h> and <sys/timeb.h>
函数功能:
返回当前时间
参数说明:
struct _timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
结构体定义于<sys/timeb.h>下
相关函数:
void _ftime32(
struct __timeb32 *timeptr
);
void _ftime64(
struct __timeb64 *timeptr
);
程序示例[1]
#include <stdio.h>
#include <sys/timeb.h>
#include <time.h>
int main( void )
{
struct _timeb timebuffer;
char timeline[26];
errno_t err;
time_t time1;
unsigned short millitm1;
short timezone1;
short dstflag1;
_ftime( &timebuffer ); // C4996
// Note: _ftime is deprecated; consider using _ftime_s instead
time1 = timebuffer.time;
millitm1 = timebuffer.millitm;
timezone1 = timebuffer.timezone;
dstflag1 = timebuffer.dstflag;
printf( "Seconds since midnight, January 1, 1970 (UTC): %I64d
",
time1);
printf( "Milliseconds: %d
", millitm1);
printf( "Minutes between UTC and local time: %d
", timezone1);
printf( "Daylight savings time flag (1 means Daylight time is in "
"effect): %d
", dstflag1);
err = ctime_s( timeline, 26, & ( timebuffer.time ) );
if (err)
{
printf("Invalid argument to ctime_s. ");
}
printf( "The time is %.19s.%hu %s", timeline, timebuffer.millitm,
&timeline[20] );
}