local_time
time_t time(time_t *tloc);
功能:获取纪元1970-01-01 00:00:00以来所经历的秒数
参数:
tloc:用来存储返回时间
返回值:成功:返回秒数, 失败:-1
-------------------------------------------------------------------------------------------------------
struct tm *localtime(const time_t *timep);
struct tm *localtime_r(const time_t *timep, struct tm *result);
struct tm {
int tm_sec; /* Seconds (0-60) */
int tm_min; /* Minutes (0-59) */
int tm_hour; /* Hours (0-23) */
int tm_mday; /* Day of the month (1-31) */
int tm_mon; /* Month (0-11) */
int tm_year; /* Year - 1900 */
int tm_wday; /* Day of the week (0-6, Sunday = 0) */
int tm_yday; /* Day in the year (0-365, 1 Jan = 0) */
int tm_isdst; /* Daylight saving time */
};
---------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <time.h>
int main()
{
time_t stim;
time(&stim);
struct tm *stm, *stm2;
stm = localtime(&stim);
printf("%04d-%02d-%02d %02d:%02d:%02d\n", stm->tm_year + 1900, \
stm->tm_mon + 1, stm->tm_mday, stm->tm_hour, stm->tm_min,\
stm->tm_sec);
stm2 = localtime_r(&stim, stm2);
printf("%04d-%02d-%02d %02d:%02d:%02d\n", stm2->tm_year + 1900, \
stm2->tm_mon + 1, stm2->tm_mday, stm2->tm_hour, stm2->tm_min,\
stm2->tm_sec);
return 0;
}
---------------------------------------------------------------------------------------------------------
最新文章
- <;<;<; chm格式文件打不开及一些问题
- Invert Binary Tree
- jQuery的eq方法
- 最短的可通过编译的C语言程序
- Python 脚本 监控数据库状态
- [转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs
- 什么时候该使用NoSQL存储数据库?
- python 32位、64位确定
- shell检测interface是否已分配ip,qt调用shell脚本
- first-,second- and third-class value
- linux sort 用法
- String Matching Content Length
- [原创]ASM动态修改JAVA函数之函数字节码初探
- .NET Core微服务之服务间的调用方式(REST and RPC)
- MySQL 笔记整理(14) --count(*)这么慢,我该怎么办?
- GBDT总结
- Java中如何设置表格处于不可编辑状态
- Python基础01_介绍_HelloWorld
- leetcode 730 Count Different Palindromic Subsequences
- 手动下载python更新后 换回以前版本