【问题标题】:Substract 5 months from a date in perl [duplicate]从perl中的日期减去5个月[重复]
【发布时间】:2014-01-30 12:16:04
【问题描述】:

我需要从 perl 中的当前日期减去 5 个月。 例如:

2014-01-30 - 5 个月 = 2013-08-30

在计算不同长度的月份时应该是准确的,例如二月。

您好,马克斯。

【问题讨论】:

    标签: perl date datetime calendar


    【解决方案1】:

    简单的方法是使用Badger::Timestamp

    use Badger::Timestamp ;
    
     my $stamp = Badger::Timestamp->new(
        year    => 2014,
        month   => 1,
        day     => 30
     );
     $stamp->adjust( months => -5  );
     print "Adjusted time stamp is : $stamp \n" ;   
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-01
      • 1970-01-01
      • 2015-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-12
      • 2020-03-16
      相关资源
      最近更新 更多