epochからYmdHMs

back
@time = (localtime)[5,4,3,2,1,0];
$time[0] += 1900;
$time[1] += 1;
$ymdhms = sprintf("%04d/%02d/%02d %02d:%02d:%02d", @time);


1行でやると、

$ymdhms = sprintf ( "%04d/%02d/%02d %02d:%02d:%02d", map { $_->[5]+=1900, $_->[4]+=1, reverse @$_[(0..3)] } [(localtime)[0..5]]);

誰か他にイケてるやりかたあったら教えて…


back