Computing.Net > Forums > Solaris > time calculation

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

time calculation

Reply to Message Icon

Name: cicicici
Date: August 29, 2003 at 20:23:33 Pacific
OS: Solaris
CPU/Ram: RS2500
Comment:

How can I calculate the time difference from for example 28/08/03 04:23:18 and 29/08/03 13:18:48. Is there any time function for this purpose?



Sponsored Link
Ads by Google

Response Number 1
Name: Jake
Date: September 4, 2003 at 12:23:01 Pacific
Reply:

I use this PERL module for various date/time functions.

The following script uses the module linked above. Note that you have to escape the space in your date/times so each date is only one argument. I called the script like this (in BASH)- "./test.pl 28/08/03\ 04:23:18 29/08/03\ 13:18:48".

#!/usr/bin/perl

use Date::Manip;

$date1 = $ARGV[0];
$date2 = $ARGV[1];

$date1 =~ m/(\d{2})\/(\d{2})\/(\d{2}) (\d{2})\:(\d{2})\:(\d{2})/;
$secs1 = Date_SecsSince1970( $2, $1, "20$3", $4, $5, $6 );
$date2 =~ m/(\d{2})\/(\d{2})\/(\d{2}) (\d{2})\:(\d{2})\:(\d{2})/;
$secs2 = Date_SecsSince1970( $2, $1, "20$3", 4, $5, $6 );

$diff = $secs2 - $secs1;

print "difference is: $diff seconds";


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: time calculation

date diffrence in solaris no %s www.computing.net/answers/solaris/date-diffrence-in-solaris-no-s/4500.html

Time Sync with Win2000 www.computing.net/answers/solaris/time-sync-with-win2000/1150.html

Recover space used by deleted files www.computing.net/answers/solaris/recover-space-used-by-deleted-files/1336.html