我想使用perl并从今天起添加两天并将其输出为unix时间.我已经找到了很多关于如何将Unix时间转换为可读时间的信息,但我需要将输出作为unix时间.我找到了这个
my $time = time; # or any other epoch timestamp
my @months = ("Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec");
my ($sec, $min, $hour, $day,$month,$year) = (localtime($time))[0,1,2,3,4,5];
# You can use 'gmtime' for GMT/UTC dates instead of 'localtime'
print "Unix time ".$time." converts to ".$months[$month].
" ".$day.", ".($year+1900);
Run Code Online (Sandbox Code Playgroud)
如何获取当前时间并添加2天并输出为Unix时间.