1
2
3
4
5
6
7
8
9
10
11
12
13
14
print localtime(time) . " ---- ". &getTimestamp . "\n";
sub getTimestamp {
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($mon < 10) { $mon = "0$mon"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
$year=$year+1900;
return $year . '_' . $mon . '_' . $mday . '__' . $hour . '_' . $min . '_' . $sec;
}
1 2 3 4
use POSIX qw/strftime/; print strftime "%Y-%m-%d %H:%M:%S", localtime(time); print "\n";
1 2 3 4
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon++; $year += 1900; $yday++; my $zeitstempel = sprintf("%04d-%02d-%02d_%02d:%02d:%02d_%d", $year, $mon, $mday, $hour, $min, $sec, $isdst); print $zeitstempel;