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. 可选参数。...
我想的得到的格式是“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(time_t *clock) 我是这样调用的 time_t ltime; struct tm *ptm; if (time(<ime) == -1) { return -1; } ptm = localtime(<ime); 问题是:指针 ptm 指向的内存是由谁分配的? 需要我 delete 这块内存吗? 不delete它,会不会造成内存泄漏?
[code] struct tm *newtime; time_t long_time; time( &long_time ); /* Get time as long integer. */ newtime = localtime( &long_time ); /* Convert to local time. */ newtime->;tm_hour.......................... [/code] 这是localtime常见的用法,问题是我们只是定义了一个tm类型的指针 newtime,localtime完成后,相应的newtime指向的空间是哪儿来的,localtime申请的?然后又是怎么释放的?
大家有没有碰到这种情况 程序A.pl运行中定时用localtime获取本地时间 比如此时取到的时间串是 2008-03-07-11-20-53 然后重新设置系统时区 [root@xx34 ~]# date 五 3月 7 11:20:58 CST 2008 [root@xx34 ~]# cp /usr/share/zoneinfo/America/New_York /etc/localtime cp:是否覆盖‘/etc/localtime’? y [root@xx34 ~]# date 四 3月 6 22:21:20 EST 2008 但还在运行的A.pl用localtime获取的时间却是 2008-03-07-11-21-53 而...