魅族mx6好还是vivox7好:C语言获取系统当前时间
来源:百度文库 编辑:九乡新闻网 时间:2024/10/02 18:35:07
C语言获取系统当前时间2009年01月15日 星期四 17:10#include
#include
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time(&rawtime); /* get the current time */
timeinfo = localtime(&rawtime);
printf("The current time is: %s\n", asctime(timeinfo));
printf("%4d-%02d-%02d %02d:%02d:%02d\n",
1900+timeinfo->tm_year, /* year */
1+timeinfo->tm_mon, /* month */
timeinfo->tm_mday, /* date */
timeinfo->tm_hour, /* hour */
timeinfo->tm_min, /* minute */
timeinfo->tm_sec); /* second */
return 0;
}
#include -- 必须的时间函数头文件
time_t -- 时间类型(time.h 定义)
struct tm -- 时间结构,time.h 定义如下:
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
time ( &rawtime ); -- 获取时间,以秒计,从1970年1月一日起算,存于rawtime
localtime ( &rawtime ); -- 转为当地时间,tm 时间结构
asctime ()-- 转为标准ASCII时间格式:
星期 月 日 时:分:秒 年
就是直接打印tm,tm_year 从1900年计算,所以要加1900,
月tm_mon,从0计算,所以要加1
其它你一目了然啦。
#include
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time(&rawtime); /* get the current time */
timeinfo = localtime(&rawtime);
printf("The current time is: %s\n", asctime(timeinfo));
printf("%4d-%02d-%02d %02d:%02d:%02d\n",
1900+timeinfo->tm_year, /* year */
1+timeinfo->tm_mon, /* month */
timeinfo->tm_mday, /* date */
timeinfo->tm_hour, /* hour */
timeinfo->tm_min, /* minute */
timeinfo->tm_sec); /* second */
return 0;
}
#include
time_t -- 时间类型(time.h 定义)
struct tm -- 时间结构,time.h 定义如下:
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
time ( &rawtime ); -- 获取时间,以秒计,从1970年1月一日起算,存于rawtime
localtime ( &rawtime ); -- 转为当地时间,tm 时间结构
asctime ()-- 转为标准ASCII时间格式:
星期 月 日 时:分:秒 年
就是直接打印tm,tm_year 从1900年计算,所以要加1900,
月tm_mon,从0计算,所以要加1
其它你一目了然啦。
C语言获取系统当前时间
如何获取系统时间
C语言 时间函数分析
时间、语言、自指系统
C/C++中怎样获取日期和时间(
python如何获取指定的系统时间串
标准C语言实现一个图书管理系统-C语言技术文档 - Firnow
java获取当前路径
收藏:VC++获得当前系统时间的几种方案
C语言嵌入式系统编程修炼之三:内存操作
嵌入式系统中FFT算法研究与实现(C语言)
ava获取时间与系统时间相差8小时终极解决方案
c语言
C语言
C语言
C语言嵌入式系统编程修炼之二:软件架构篇 模块划分
C语言嵌入系统编程修炼-性能优化 资料引用:http://www.knowsky.com/395176.html
11嵌入式系统中FFT算法研究与实现(C语言)
const用法详解 - C/C / C 语言
java获取当前路径(包含tomcat)2
C语言经典教程
C语言系列教程
C语言谜题
C语言指针