Connecting Tech Pros Worldwide Forums | Help | Site Map

Diffrence between timestamps

Member
 
Join Date: May 2008
Posts: 51
#1: Oct 22 '08
hi,
i have got two timestamps as under:
Expand|Select|Wrap|Line Numbers
  1.  my $time1 = "2008-10-06  11:20:23";
  2. my $time2 = "2008-15-06  12:20:12";
  3.  
i need to get difference between $time1 and $time2 i.e. i want $time3 should be equal to $time2-$time1. Is there any module to do the same? Please tell me.

Regards,
Pavan

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Oct 22 '08

re: Diffrence between timestamps


Use the Time::Local module to convert the dates into epoch seconds then compute the difference. See the Time::Local modules documentation for details. It is a core module so your installation of perl will have it. If you get stuck after reading the documentation and writing and trying some code, post back.
Reply


Similar Perl bytes