ChinaUnix.net
相关文章推荐:

localtime 函数

1、Definition and Usage 定义和用法 The localtime() function returns an array that contains the time components of a Unix timestamp. localtime()函数的作用是:以数组的形式返回本地时间。 2、Syntax 语法 localtime(timestamp,is_associative) Parameter参数 Description描述 timestamp Optional. Specifies the date or time to be formatted. If no timestamp is specified, it uses the current local time. 可选参数。...

by ruoyisiyu - php文档中心 - 2007-09-11 17:03:19 阅读(1017) 回复(0)

相关讨论

我想的得到的格式是“2008-9-19 02:03:23”, 但是用localtime()输出时得到的是“2008-9-19 2:3:23” 有哪指点一下或者有其他函数。部分源代码如下; my ($a,$b,$c,$d,$e,$f) = localtime($atime_sec); $f=($f+1900); $e=($e+1); my $atclrtime = "$f-$e-$d $c:$b:$a"

by liuxl2008 - Perl - 2008-09-19 21:37:03 阅读(3461) 回复(2)

localtime函数的原型如下: struct tm * localtime(const time_t *timep); 其中time_t是一个long型的结构,tm结构如下: struct tm { int tm_sec; /* seconds */ int tm_min; /* minutes */ int tm_hour; /* hours */ int tm_mday; /* day of the month */ int tm_mon; /* month */ ...

by ifreecoding - Linux新手园地 - 2013-06-09 17:15:06 阅读(3274) 回复(2)

[code] char *time_print(char *buf_time) { int ret; char buf[27]; time_t clock; char *temp; buf_time=malloc(sizeof(buf_time)); //time (&clock); clock = time (NULL); memset(buf, 0, 27); ret = strftime (buf, 27, "%Y/%m/%d %H:%M:%S", localtime (&clock)); if (ret == 0) { printf("ERROR:strftime error\n"); return NULL; } strcpy(buf_time,buf); // strcpy(temp, buf); // b...

by yysjacky - Linux环境编程 - 2009-02-26 10:40:28 阅读(4119) 回复(12)

这个函数什么情况下回出错:lol:

by zhj9811220 - C/C++ - 2005-03-03 11:03:35 阅读(612) 回复(0)
by yangfengwait - Perl - 2008-09-02 11:51:09 阅读(3021) 回复(8)

-bash-2.05b$ g++ -v Reading specs from /usr/local/lib/gcc/hppa2.0w-hp-hpux11.11/3.4.3/specs Configured with: ./configure : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure : (reconfigured) ./configure Thread model: single gcc version 3.4.3 一个cpp文件中包含这样的代码: [code] #include time_t tt; struct tm ut;...

by dajun - C/C++ - 2006-10-09 17:40:57 阅读(5395) 回复(13)

UNIX中用一个long保存时间,内容是1970年以来的秒数,并可用localtime转换到结构tm中,以便格式化输出(年月日时分秒),但是已知一个时间(年月日时分秒)的话,如何将其转换为上述的long,即1970年以来的秒数。

by siceng - C/C++ - 2004-08-20 14:27:36 阅读(2431) 回复(2)

我发现该函数在c程序中可以正常使用,但在c++程序中无法编译,哪位大侠知道原因? 谢了先!

by 岁月如烟 - C/C++ - 2003-07-04 15:26:22 阅读(4225) 回复(13)

有些函数在/usr/include/*.h中声明了,并且在程序中可以调用, 但是这些函数函数体在哪里呢? 比如/usr/include/time.h中声明了localtime函数, 但为什么就是找不到其函数体的源码呢? 我把内核整个都搜索了一遍,没有,coreutils里也没有,到底在哪里呢?! 这个问题令小弟很迷惑...........

by fwm1981 - 程序开发 - 2006-12-20 14:46:38 阅读(886) 回复(2)

有些函数在/usr/include/*.h中声明了,并且在程序中可以调用, 但是这些函数函数体在哪里呢? 比如/usr/include/time.h中声明了localtime函数, 但为什么就是找不到其函数体的源码呢? 我把内核整个都搜索了一遍,没有,coreutils里也没有,到底在哪里呢?! 这个问题令小弟很迷惑...........

by fwm1981 - Linux环境编程 - 2006-12-20 14:46:38 阅读(1647) 回复(2)