c语言获取系统时间 程序实现
来源:互联网 发布:服装erp软件xyerp 编辑:程序博客网 时间:2024/05/20 11:24
1、
#include"stdafx.h"
#include<stdio.h>
#include<time.h>
#include<Windows.h>
int main(void)
{
time_t timer=time(NULL);
printf("ctime is%s\n",ctime(&timer));//得到日历时间
system("pause");
return 0;
}
输出为:
ctime isSun Apr 20 09:07:27 2014
请按任意键继续. . .
2、
#include"stdafx.h"
#include<time.h>
#include<stdio.h>
#include<dos.h>
#include<Windows.h>
int main()
{
time_t timer;
struct tm*tblock;
timer=time(NULL);
tblock=localtime(&timer);
printf("Localtimeis:%s",asctime(tblock));
system("pause");
return 0;
}
输出为:
Localtimeis:Sun Apr 20 09:10:00 2014
请按任意键继续. . .
3、
#include"stdafx.h"
#include<Windows.h>
#include<stdio.h>
#include<time.h>
int main()
{
time_t t;
time(&t);
printf("Today's date and time:%s",ctime(&t));
system("pause");
return 0;
}
输出为:
Today's date and time:Sun Apr 20 09:13:23 2014
请按任意键继续. . .
4、
#include"stdafx.h"
#include<Windows.h>
#include<time.h>
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
time_t first,second;
//system("cls");//clrscr()是TC里的
first=time(NULL);
Sleep(2000);//延迟函数,delay()是TC的
second=time(NULL);
printf("The difference is:%f seconds",difftime(second,first));//得到两次机器时间差,单位为秒
system("pause");
return 0;
}
输出为:
The difference is:2.000000 seconds请按任意键继续. . .
5、
#include"stdafx.h"
#include<Windows.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<dos.h>
#include"stdafx.h"
#include<Windows.h>
char*tzstr="TZ=PST8PDT";//数字来改变时区,8代表
int main()
{
time_t t;
struct tm*gmt,*area;
putenv(tzstr);//把字符串加到当前环境中
tzset();//UNIX兼容函数,用于得到时区,在DOS环境下无用途
t=time(NULL);
area=localtime(&t);
printf("Localtime is:%s",asctime(area));
gmt=gmtime(&t);//得到以结构tm表示的时间信息
printf("GMT is:%s",asctime(gmt));
system("pause");
return 0;
}
输出为:
Localtime is:Sat Apr 19 18:34:40 2014
GMT is:Sun Apr 20 01:34:40 2014
请按任意键继续. . .
http://baike.baidu.com/view/1741851.htm
- c语言获取系统时间 程序实现
- C语言获取系统时间
- C语言获取系统时间
- C语言获取系统时间
- c语言获取系统时间
- C语言获取系统时间
- C语言获取系统时间
- c语言获取系统当前时间
- 用C语言获取系统时间
- linux下c语言获取系统时间
- linux c语言获取系统时间
- Linux C 语言 获取系统时间信息
- Linux C 语言 获取系统时间信息
- C语言获取系统时间方式
- C语言中获取当前系统时间
- C语言获取系统时间&求时间差
- Linux C 语言 获取系统时间信息
- Linux C 语言 获取系统时间信息
- Hadoop I/O
- 当然
- 《Linux Device Drivers》第四章 调试技术——note
- Dia 闪烁一下界面就不见了
- 为自己开导的指针混淆概念
- c语言获取系统时间 程序实现
- java中的面向对象
- 《Linux Device Drivers》第五章 并发和竞态——note
- 智力题之25匹马比赛角逐前三
- fuser 命令的介绍
- struts2基于验证框架的输入校验
- 第八2周项目1-实现复数类中的运算符重载
- 《Linux Device Drivers》第六章 高级字符驱动程序操作——note
- leetcode之Trapping Rain Water