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"
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 */ ...
[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...
-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
UNIX中用一个long保存时间,内容是1970年以来的秒数,并可用localtime转换到结构tm中,以便格式化输出(年月日时分秒),但是已知一个时间(年月日时分秒)的话,如何将其转换为上述的long,即1970年以来的秒数。
有些函数在/usr/include/*.h中声明了,并且在程序中可以调用, 但是这些函数的函数体在哪里呢? 比如/usr/include/time.h中声明了localtime函数, 但为什么就是找不到其函数体的源码呢? 我把内核整个都搜索了一遍,没有,coreutils里也没有,到底在哪里呢?! 这个问题令小弟很迷惑...........
有些函数在/usr/include/*.h中声明了,并且在程序中可以调用, 但是这些函数的函数体在哪里呢? 比如/usr/include/time.h中声明了localtime函数, 但为什么就是找不到其函数体的源码呢? 我把内核整个都搜索了一遍,没有,coreutils里也没有,到底在哪里呢?! 这个问题令小弟很迷惑...........