Thread Formatierung eines Datumwertes aus der DB (42 answers)
Opened by PERLScripter at 2014-12-08 11:58

Raubtier
 2014-12-09 17:56
#178748 #178748
User since
2012-05-04
1076 Artikel
BenutzerIn
[default_avatar]
Um nochmal GwenDragons Beispiel zu bemühen:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl

use strict;
use warnings;

use Time::Piece;
use Time::Seconds;

my $DATEFORMAT_FROM = '%d.%m.%y %H:%M:%S';
my $DATEFORMAT_TO = '%Y%m%d%H%M%S';  

my $from = "05.12.14 12:00:44,050000";
$from =~ s/,\d+//;
my $to = "05.12.14 12:00:44,070425";
$to =~ s/,\d+//;

my $t1 = Time::Piece->strptime( $from, $DATEFORMAT_FROM );
my $t2 = Time::Piece->strptime( $to,   $DATEFORMAT_FROM );
if ( $t1 == $t2 ) {
    $t1 += ONE_MINUTE;
    $t1 = $t1->strftime($DATEFORMAT_TO);

    $t2 -= ONE_MINUTE;
    $t2 = $t2->strftime($DATEFORMAT_TO);
}

print $t1, "\n", $t2, "\n";

View full thread Formatierung eines Datumwertes aus der DB