如何使用perl找到给定日期的下一个日期? [英] How can I find the next date of given date using perl?

查看:38
本文介绍了如何使用perl找到给定日期的下一个日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到任何日期的下一个日期.

I need to find the next date of any date.

use strict;

my $entered_date="2011-11-30";

在上面的代码中,我想找到存储在 $entered_date 变量中的日期的下一个日期...请分享您的解决方案....

In the above code I want to find the next date of the date, which stored in $entered_date variable... Please share your solutions....

提前致谢...

推荐答案

perl -MDate::Calc -E ' use Date::Calc qw(Add_Delta_Days);say join "-", Add_Delta_Days(2011,11,30,1);'

2011-12-1

在脚本中(不是很安全)

In a script (not very safe)

use Date::Calc qw(Add_Delta_Days);
my $entered_date = "2011-12-31";
print join "-", Add_Delta_Days(split(/-/,$entered_date),1);'

2012-1-1

这篇关于如何使用perl找到给定日期的下一个日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆