免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2404 | 回复: 5
打印 上一主题 下一主题

求助 取消在定义时间变量后的回车 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-13 10:01 |只看该作者 |倒序浏览
2可用积分
求助 取消在定义时间变量后的回车 又是菜菜的问题 麻烦大家了我的定义时间和日期的时候走了弯路了
my $time=`date +%F"  "%T`;
chomp $time;
my $date = `date +%Y%m%d`;
chomp $date;
my $oldmonth = `date +%Y%m%d -d "-30 day"`;
chomp $oldmonth;

只有使用chomp取消回车,是不是我这样定义时间的原因

最佳答案

查看完整内容

localtime EXPR localtime Converts a time as returned by the time function to a 9-element list with the time analyzed for the local time zone. Typically used as follows: # 0 1 2 3 4 5 6 7 8 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);All list elements are numeric, and come straight out of ...

论坛徽章:
0
2 [报告]
发表于 2008-06-13 10:01 |只看该作者
localtime EXPR
localtime
Converts a time as returned by the time function to a 9-element list with the time analyzed for the local time zone. Typically used as follows:

    #  0    1    2     3     4    5     6     7     8
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                                                localtime(time);

All list elements are numeric, and come straight out of the C `struct tm'. $sec, $min, and $hour are the seconds, minutes, and hours of the specified time.


______________________

lazy, so lazy.

论坛徽章:
0
3 [报告]
发表于 2008-06-13 10:04 |只看该作者
perldoc -f localtime

论坛徽章:
0
4 [报告]
发表于 2008-06-13 10:06 |只看该作者
cobrawgl大哥 给点代码好吗

论坛徽章:
0
5 [报告]
发表于 2008-06-13 10:29 |只看该作者
应该是因为你使用了反撇号(`)来获取输出导致的回车
其实获取系统时间最简单的是用楼上说的localtime
比如$time=localtime
在我的系统里print $time得到的就是:Fri Jun 13 10:18:59 2008(不同的系统会有些小差别)

论坛徽章:
0
6 [报告]
发表于 2008-06-13 10:30 |只看该作者
好滴 谢谢cobrawgl大哥,找到了 哇哈哈
PS : 大哥 我要的是代码不是perldoc
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP