Perl statements to generate (DB2) timestamp
Do you want to generate a timestamp in external DB2 format YYYY-MM-DD-HH.MM.SS.ssssss?
Use either following functions which is already part of the xmpPerl.pm function library:
$TS = `date +%Y-%m-%d-%H.%M.%S`; # yyyy-mm-dd-hh.mm.ss $TS = &trim($TS); $TS.= ".000000"; # milliseconds = 0 return $TS; } # Unix does no not support milliseconds. # Code not portable e.g. to windows!
Or try following Perl statements which are compatible to POSIX and are portable to other platforms:
sub getTimestamp { my $TS; use Time::localtime; $tm = localtime; # structure with 9 elements: # $tm->$sec # $tm->$min # $tm->$hours # $tm->$mday # 1-31 # $tm->$month # 1-12 # $tm->$year # 1-138 + 1900 # $tm->$wday # 0-6, 0=Sunday # $tm->$yday # 1-366 # $tm->$sec # 0 or 1, true=daylight saving time # or: ($D,$MONAT,$J) = (localtime) [3,4,5]; # element 0 = $SEC
Comments
Comments are closed.