Computing.Net > Forums > Solaris > time calculation

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

time calculation

Reply to Message Icon

Original Message
Name: cicicici
Date: August 29, 2003 at 20:23:33 Pacific
Subject: time calculation
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?


Report Offensive Message For Removal


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";


Report Offensive Follow Up For Removal







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



Results for: time calculation

date diffrence in solaris no %s
    Summary: In general, time calculations in the shell are difficult. Consider using perl for date and time calculations for an OS independent answer. ========================== #!/usr/bin/perl -w use strict; use...
www.computing.net/answers/solaris/date-diffrence-in-solaris-no-s/4500.html

total time spent for IO requests
    Summary: Hello, I am testing SNMP agent on SUN server. By using SNMP, I can get many performance values. an example is below. As can be seen in this examle, parameter names (counter names) and values are prese...
www.computing.net/answers/solaris/total-time-spent-for-io-requests/4376.html

ftp: connect: Connection timed out
    Summary: In Solaris10 , I can able to ping to the remote FTP Server , but while try to connect through FTP it is showing "connection timed out".From other servers I can download the files from the same FTP s...
www.computing.net/answers/solaris/ftp-connect-connection-timed-out/4993.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History






Data Recovery Software