Dotcpp  >  编程教程  >  time.h头文件  >  C语言tzset()函数:对UNIX操作系统的时间兼容性

C语言tzset()函数:对UNIX操作系统的时间兼容性

点击打开在线编译器,边学边练

函数名: tzset

头文件:<time.h>

函数原型: void tzset(void);

功 能: 对UNIX操作系统的时间兼容性

参数: 没有参数

返回值:没有返回值 


程序例: 实现UNIX时间兼容

#include<stdio.h>

#include<time.h>

int main(void){

   time_t td;

   if(putenv("TZ=PST8PDT")==-1){  // 设置环境变量,并判断是否成功

      printf("Unable to set tz\n");

      return 0;

   }

   tzset();  //设置UNIX时间兼容

   time(&td);

   printf("Current time = %s\n", asctime(localtime(&td)));

   return 0;

}

运行结果

Current time = Tue Jun 16 06:32:06 2020



本文固定URL:https://www.dotcpp.com/course/578

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)