DateTimeモジュールを使用しています。しかし、それは間違った時間を提供しています。以下のコードを検討してください。
#!/usr/bin/perl -w
use strict;
use Time::localtime;
my $now = ctime();
print $now."\n";
print "------------------------------\n";
use DateTime;
my $dt = DateTime->now;
print $dt."\n";
そして、その出力は次のとおりです。
Wed Dec 26 22:11:52 2012
------------------------------
2012-12-27T06:11:52
ご覧のとおり、DateTime
出力は8時間進んでいますが、これは間違っています。Linuxdate
コマンドの出力は次のとおりです。
# date
Wed Dec 26 22:13:17 PST 2012
したがって、date
コマンドの出力は出力の出力と一致しtime::localtime
ます。
DateTime
モジュールの使用でどこが間違っているのかを理解するのを手伝ってくれませんか。
-ありがとう。
アップデート:
hte CPANドキュメントから:
DateTime->now( ... )
This class method is equivalent to calling from_epoch() with the value returned from Perl's time() function. Just as with the new() method, it accepts "time_zone" and "locale" parameters.
By default, the returned object will be in the UTC time zone.
したがって、返される時刻はUTCであるようです。ただし、私がPSTにいるタイムゾーン。おそらくそれが私が別の時間を見る理由です。