in reply to Formatting MySQL's TIMESTAMP
Just take care of dates > 2038 on 32-bit time systems...use Time::Local; my $timestamp = "20011130053055"; # timestamp(14) my $epoch = &ConvertTimestamp14ToEpochSeconds($timestamp); print $timestamp; sub ConvertTimestamp14ToEpochSeconds { my ($timeStamp) = @_; my $unpackPattern = "a4 a2 a2 a2 a2 a2"; my @dateList = reverse unpack($unpackPattern, $timestamp); $dateList[4]--; $dateList[5] -= 1900; my $epochSeconds = timelocal(@dateList); return ($epochSeconds); } # ConvertTimestamp14ToEpochSeconds
Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"
|
---|