gpt4 book ai didi

perl - 如何在 Perl 中找到比给定日期早三天的日期?

转载 作者:行者123 更新时间:2023-12-03 23:57:33 25 4
gpt4 key购买 nike

如何在 Perl 中找到比给定日期早 3 天的日期,格式为 YYYY-MM-DD?

最佳答案

Date::Calc 是这里的冠军模块:

use strict;
use warnings;
use Date::Calc qw(Add_Delta_YMD);

my $startDate = '2000-01-01';
my ($startYear, $startMonth, $startDay) = $startDate =~ m/(\d{4}-(\d{2})-\d{2})/;

# 1 year, 2 months, 3 days, after startDate
my $endDate = join('-', Add_Delta_YMD($startYear, $startMonth, $startDay, 1, 2, 3));
该模块有大量的时间转换例程,尤其是那些处理增量的。 DateTime Date::Manip 也值得一试。

关于perl - 如何在 Perl 中找到比给定日期早三天的日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1365922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com