hi,
any idea how to change the time format from below data on 3rd & 4th column into milisecond (epoch), bcoz currently Datetime package is not installed in my machine.
source ALL30 2191967708 201211020915 201303020923
expected result ALL30 2191967708 1351822500000 1362190980000
thanks#!/usr/bin/perl use strict; use warnings; use DateTime; use DateTime::Format::Strptime; my $file = $ARGV[0] or die "Need to get CSV file on the command line\n +"; my $outfile = "output_date.txt"; my $sum = 0; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; open (OUTFILE, "> $outfile") || die "ERROR: opening $outfile\n"; while (my $line = <$data>) { chomp $line; my @fields = split "\t" , $line, -1;; my $formatter= new DateTime::Format::Strptime(pattern => '%Y%m +%d%T'); my $sum1 = "$formatter->parse_datetime($fields[2])"; my $sum2 = "$formatter->parse_datetime($fields[3])"; $fields[2] = "$sum1"; $fields[3] = "$sum2"; # $line= print join( "\t", @fields ) . "\n" ; print OUTFILE "@fields\n"; } close ($data); close (OUTFILE);
In reply to change the time format into milisecond by hyans.milis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |