C语言实现获取系统时间,转换成时分秒年月日 (vs2015亲测可用)
2016-08-21 17:15
786 查看
<span style="color: rgb(51, 51, 51); font-family: 'Microsoft YaHei'; font-size: 14px; line-height: 24px;">基本思路:首先获取系统时钟,然后转换格式为:年月日时分秒(YYYYMMDDHHMMSS)</span>
<pre name="code" class="cpp"><span>#include <stdio.h> #include <time.h> </span>
int main()
{
time_t nowtime;struct tm timeinfo;time(&nowtime);localtime_s(&timeinfo,&nowtime);int year, month, day, hour, min, sec;year = 1900 + timeinfo.tm_year;month = 1 + timeinfo.tm_mon;day = timeinfo.tm_mday;hour = timeinfo.tm_hour;min = timeinfo.tm_min;sec
= timeinfo.tm_sec;printf("系统时间:%4d-%02d-%02d %02d:%02d:%02d\n",year, month, day, hour, min, sec);
<span style="white-space:pre"> </span>return 0;<pre name="code" class="cpp">}
相关文章推荐
- SQL时间第一期_获取系统年月日时分秒
- android获取系统当前年月日时分秒的时间
- solaris/unix/linux 获取系统时间的方法--精确到年月日时分秒
- C语言实现判断闰年、从常规时间到卫星系统时间的转换
- c语言获取系统时间 程序实现
- ios开发 获取系统时间 取得当前的年月日,当前的时分秒获得,周几和星期几获得
- cocos2d-x 获取系统时间 年月日时分秒还有毫秒
- Android 用Time和Calendar获取系统当前时间源码分享(年月日时分秒周几)
- 获取系统当前时间,年月日时分秒
- 如何获取系统时间,年月日时分秒?
- php实现显示网站运行时间-秒转换年月日时分秒
- c语言里面的调用显示系统时间的函数及实现过程是什么
- Symbian使用TTime类获取系统时间并转换为描述符
- 以字符串形式返回当前系统时间,默认格式为“年月日时分秒”
- symbian获取系统时间并转换为字符串发布
- C语言下获取当前时间并格式化成字符串的方法-可用作截图或者录像的文件名
- C语言中time_t到.NET的转换与更改系统时间
- Linux下获得系统时间的C语言的实现方法
- C语言获取系统时间的几种方式
- C++ 获取系统时间并且转换成字符串