Thread localtime ausgeben in Zahl?
(10 answers)
Opened by Alexander at 2012-03-04 12:53 2012-03-04T11:53:08 Alexander ... um auch das noch zu beantworten: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 my $datum = '01.02.2012'; # 1. Variante my $zahl_1 = join('', reverse split(/\./, $datum)); # 2. Variante, geht auch, wenn führende 0 (Tag/Monat) fehlt: my $zahl_2 = sprintf('%4d%02d%02d', reverse split(/\./, $datum)); print "$datum\n\$zahl_1: $zahl_1\n\$zahl_2: $zahl_2\n"; Über Datumsberechnungen und -formatierungen haben sich schon viele schlaue Leute Gedanken gemacht und diese in Modulen zugänglich gemacht (s.u.), bevor Du also Räder neu erfindest, schau mal im CPAN :) Gruß FIFO Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|