Operating System - HP-UX
1822004 Members
4032 Online
109639 Solutions
New Discussion юеВ

Re: perl :: pls help conversion timestamp diff format to seconds

 
viral
Occasional Contributor

perl :: pls help conversion timestamp diff format to seconds

pls help with converting difference of timestamp format (dd.mm.yyyy:hh.mm.ss) to no of seconds or milliseconds.
3 REPLIES 3
morganelan
Trusted Contributor

Re: perl :: pls help conversion timestamp diff format to seconds

viral
Occasional Contributor

Re: perl :: pls help conversion timestamp diff format to seconds

i wish to convert the following timestamp format (dd.mm.yyyy:hh.mm.ss) to give an example (01.12.2004:03:23:21) to no of seconds?
actually its like two strings in the following timestamp format would come and we need a difference of it in seconds or milliseconds?
pls help with this
harry d brown jr
Honored Contributor

Re: perl :: pls help conversion timestamp diff format to seconds

download and install http://search.cpan.org/CPAN/authors/id/S/SB/SBECK/DateManip-5.44.tar.gz

use Date::Manip qw(UnixDate);
($date,$time) = split(/:/, $YOURDATE);
($day,$mon,$year) = split(/\./, $date);
$time =~ s/\./:/g;
$newdatefmt = ${year}."/".${mon}."/".${day}." ".$time;
printf("New date fmt is %s\n",$newdatefmt);
$secs = &UnixDate($newdatefmt,"%s");
printf("Number of secs is %s\n",$secs);

You don't need to use milliseconds because the closest you have is "seconds".

live free or die
harry d brown jr
Live Free or Die