perl xml dom get_timestamp()格式

perl xml dom get_timestamp()格式,xml,perl,dom,scripting,timestamp,Xml,Perl,Dom,Scripting,Timestamp,我使用get_timestamp()来获取时间戳,得到的回报是: 2010-10-5T11:12:34 但我需要的是2010-10-05T11:12:34 我需要在dd格式的日期,即使它是一个数字的日期。有什么办法我能做到吗?使用get_timestamp()时我可以指定格式吗?您实际上没有指定模块get_timestamp()的来源。但是扔掉它,使用: 谢谢你的回复,我用:date+%Y-%m-%d“T”“%T”-从bash本身获得了它。 use DateTime; my $dt = Date

我使用get_timestamp()来获取时间戳,得到的回报是:

2010-10-5T11:12:34

但我需要的是2010-10-05T11:12:34


我需要在dd格式的日期,即使它是一个数字的日期。有什么办法我能做到吗?使用get_timestamp()时我可以指定格式吗?

您实际上没有指定模块
get_timestamp()
的来源。但是扔掉它,使用:


谢谢你的回复,我用:
date+%Y-%m-%d“T”“%T”
-从bash本身获得了它。
use DateTime;
my $dt = DateTime->new(
    year => 2010,
    month => 10,
    day => 5,
    hour => 11,
    minute => 12,
    second => 34
);
print $dt->strftime('%Y-%m-%dT%T'), "\n";

# it also magically stringifies to your desired format:
print $dt . '', "\n";