我希望将系统日期转换为ISO 8601格式。代码:
my $now = time();
my $tz = strftime("%z", localtime($now));
$tz =~ s/(\d{2})(\d{2})/$1:$2/;
print "Time zone *******-> \"$tz\"\n";
# ISO8601
my $currentDate = strftime("%Y-%m-%dT%H:%M:%S", localtime($now)) . $tz;
print "Current date *******-> \"$currentDate\"\n";
当前输出为:
Time zone *******-> "-04:00"
Current date *******-> "2014-06-03T03:46:07-04:00"
我希望当前日期的格式为“2014-07-02T10:48:07.124Z”,以便我可以计算两者之间的差异。
strftime
函数? - chorobaDateTime::Format::ISO8601
。 - Biffen