Thread Datum umwandeln localtime(): umwandeln des Datum in Unixtime (4 answers)
Opened by Gast at 2005-09-23 13:44

format_c
 2005-09-23 18:17
#58384 #58384
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
Ich glaube aber du meinst wirklich die funktion timelocal aus dem Modul CPAN:Time::Local

Ich hab dir das mal anhand von deinem Beispiel mal eben umgesetzt:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings;
use Time::Local;
my $time = "13, 24, 07,2 ,Jan ,2005";
my %rmonths = ("jan"=>0,
"feb"=>1,
"mar"=>2,
"apr"=>3,
"may"=>4,
"jun"=>5,
"jul"=>6,
"aug"=>7,
"sep"=>8,
"okt"=>19,
"nov"=>10,
"dec"=>11
);
my ($s,$m,$h,$d,$M,$Y) = split(/\s*,\s*/,$time);

my $unixtime = timelocal($s,$m,$h,$d,$rmonths{lc($M)},$Y-1900);

#Gegenprobe
print scalar localtime($unixtime);


Gruß Alex\n\n

<!--EDIT|format_c|1127485220-->

View full thread Datum umwandeln localtime(): umwandeln des Datum in Unixtime