ChinaUnix.net
相关文章推荐:

linux 时间函数

linux c下有现成的将时间转换成秒的函数吗... 例如: 2010-10-15 18:34:35 转换成秒......... 多谢............

by ruchong - C/C++ - 2010-03-16 11:29:00 阅读(2120) 回复(11)

相关讨论

linux时间函数 asctime(将时间和日期以字符串格式表示) 相关函数 time,ctime,gmtime,localtime 表头文件 #include 定义函数 char * asctime(const struct tm * timeptr); 函数说明 asctime()将参数timeptr所指的tm结构中的信息转换成真实世界所使用的时间日期表示方法,然后将结果以字符串形态返回。此函数已经由时区转换成当地时间,字符串格式为:“Wed Jun 30 21:49:08 1993\n” 返回值 若再调用相关的时间日期函...

by wf361 - Linux文档专区 - 2008-08-22 22:16:06 阅读(937) 回复(0)

想写个函数,输入是一个日期的字符串,比如2005-08-09.输出是0-6这7个数字.代表这一天是星期几. int day_of_week(const char *datestring) 大概这么个原型.但不知道怎么实现.因为输入的这个日期可以是以前的,所以相当于万年历一样,知道那天日期就可以查星期几了. 我知道有种计算方法,但我想能不能利用linux函数实现. mktime()可以吧tm结构的东西还原为秒数,但我只提供了日期,所以只能填充一个不完整的tm结构.所以也返回不了秒数给...

by bigapple2008 - C/C++ - 2005-08-09 16:57:22 阅读(2215) 回复(1)

由于linux对man date -d 参数说的比较模糊,故举例如下: # -d, --date=STRING display time described by STRING, not `now' For linux [root@Gman root]# date -d next-day +%Y%m%d 20060328 [root@Gman root]# date -d last-day +%Y%m%d 20060326 [root@Gman root]# date -d yesterday +%Y%m%d 20060326 [root@Gman root]# date -d tomorrow +%Y%m%d 20060328 [root@Gman root]# date -d last-month +%Y%m 200602 [root@Gman roo...

by dow - Linux文档专区 - 2008-08-19 01:42:43 阅读(711) 回复(0)

由于linux对man date -d 参数说的比较模糊,故举例如下: # -d, --date=STRING display time described by STRING, not `now' For linux [root@Gman root]# date -d next-day +%Y%m%d 20060328 [root@Gman root]# date -d last-day +%Y%m%d 20060326 [root@Gman root]# date -d yesterday +%Y%m%d 20060326 [root@Gman root]# date -d tomorrow +%Y%m%d 20060328 [root@Gman root]# date -d last-month +%Y%m 200602 [root@Gman ro...

by younghawk - Linux文档专区 - 2008-08-18 16:04:08 阅读(603) 回复(0)

函数: #include char *asctime(const struct tm *tm); char *asctime_r(const struct tm *tm, char *buf); char *ctime(const time_t *timep); char *ctime_r(const time_t *timep, char *buf); struct tm *gmtime(const time_t *timep); struct tm *gmtime_r(const time_t *timep, struct tm *result); struct tm *localtime(const time_t *timep); struct tm ...

by greentown - Linux文档专区 - 2007-05-12 13:03:03 阅读(1136) 回复(0)

时间函数(13) 函数分类: 1. 设置时间: settimeofday, tzset 2. 获取时间: time, ftime, gettimeofday 3. 时间格式转换: mktime, strftime; gmtime, localtime; asctime, ctime 4. 其他: clock, difftime asctime: 将时间和日期以字符串格式表示 头文件: time.h 函数定义: char *asctime(const struct tm *timeptr); 说明: asctime()将函数timeptr所指的tm结构中的信息转换成现实世界所使用的时间日期表示方法, 然后将结果以字符...

by newcch - Linux文档专区 - 2009-06-29 21:23:47 阅读(1108) 回复(0)

1、时间类型。linux下常用的时间类型有4个:time_t,struct timeval,struct timespec,struct tm。

(1)time_t是一个长整型,一般用来表示用1970年以来的秒数。

(2)Struct timeval有两个成员,一个是秒,一个是微妙。

struct timeval <font color=linux-时间相关结构...

by DerekGuo_lzu - 移动操作系统 - 2011-12-22 08:51:16 阅读(866) 回复(0)

1、时间类型。linux下常用的时间类型有4个:time_t,struct timeval,struct timespec,struct tm。 (1)time_t是一个长整型,一般用来表示用1970年以来的秒数。 (2)Struct timeval有两个成员,一个是秒,一个是微妙。 struct timeval { long tv_sec; /**//* seconds */ long tv_usec; /**//* microseconds */ }; (3)struct timespec有两个成员,一个是秒,一个是...

by xxfihm - Linux文档专区 - 2008-11-18 17:08:18 阅读(866) 回复(0)

------------------------------------------------------------ asctime(将时间和日期以字符串格式表示) 相关函数 time,ctime,gmtime,localtime 表头文件 #include 定义函数 char * asctime(const struct tm * timeptr); 函数说明 asctime()将参数timeptr所指的tm结构中的信息转换成真实世界所使用的时间日期表示方法,然后将结果以字符串形态返回。此函数已经由时区转换成当地时间,字符串格式为:“Wed Jun 30 21:49:...

by wind_xp - Linux文档专区 - 2008-10-31 18:27:22 阅读(741) 回复(0)

日期时间篇 asctime ctime gettimeofday gmtime localtime mktime settimeofday time asctime(将时间和日期以字符串格式表示) 相关函数 time,ctime,gmtime,localtime 表头文件 #include 定义函数 char * asctime(const struct tm * timeptr); 函数说明 asctime()将参数timeptr所指的tm结构中的信息转换成真实世界所使用的时间日期表示方法,然后将结果以字符串形态返回。此函数已经由时区转换成当地时间,字符串格式为:...

by kikyguan - Linux文档专区 - 2008-07-14 23:07:10 阅读(614) 回复(0)