Thread Zeitermittlung unter Perl? (10 answers)
Opened by skontox at 2003-08-28 15:53

Dubu
 2003-08-29 01:45
#81172 #81172
User since
2003-08-04
2145 Artikel
ModeratorIn + EditorIn

user image
[E|B
,28.08.2003, 14:14]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
($sec, $min, $hours, $day, $month, $year, $wday, $yday, $isdst) = localtime();

$month += 1;
$year += 1900;
$min = "0$min" if($min < "10");
$sec = "0$sec" if($sec < "10");
$hours = "0$hours" if($hours < "10");
$day = "0$day" if($day < "10");
$month = "0$month" if($month < "10");

print "Heute ist der $day.$month.$year. Es ist $hours:$min:$sec Uhr!";

Oder so, etwas kuerzer:

Code: (dl )
1
2
3
4
5
my ($sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst) = localtime();

printf "Heute ist der %02d.%02d.%04d, %02d:%02d:%02d.\n", $day, $month+1, $year+1900, $hour, $min, $sec;
_ _END_ _
Heute ist der 28.08.2003, 23:44:35.


Oder einfach so, inklusive locale:

Code: (dl )
1
2
3
4
use POSIX;
print strftime ("Heute ist %A, der %d. %B %Y, %H:%M:%S\n", localtime());
_ _END_ _
Heute ist Donnerstag, der 28. August 2003, 23:44:35

View full thread Zeitermittlung unter Perl?