#include <sys/time.h>
int gettimeofday(struct timeval *tv, struct timezone *tz);
struct timeval {
time_t tv_sec; /* 秒 */
suseconds_t tv_usec; /* 毫秒 */
};
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of DST correction */
};
ST_NONE /* 不使用 */
DST_USA /* 美国 */
DST_AUST /* 澳洲 */
DST_WET /* 西欧 */
DST_MET /* 中欧 */
DST_EET /* 东欧 */
DST_CAN /* 加拿大 */
DST_GB /* 大不列颠 */
DST_RUM /* 罗马尼亚*/
DST_TUR /* 土耳其*/
DST_AUSTALT /* 澳洲(1986年后) */
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
int main()
{
struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
printf ("tv_sec: %d\n", tv.tv_sec);
printf ("tv_usec: %d\n", tv.tv_usec);
printf ("tz_minuteswest: %d\n", tz.tz_minuteswest);
printf ("tz_dsttime: %d\n", tz.tz_dsttime);
return 0;
}
./gettimeofday
tv_sec: 1324369876
tv_usec: 279337
tz_minuteswest: 0
tz_dsttime: 0
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |