How far is given date from current time?

give a date and time:

Jun 12 21:05:16
06-12-2012 21:05:16
2012/06/12 21:05:16

How can i subtract these dates and times from the current date and time and get back the difference in seconds?

a one liner like:

echo "Jun 12 21:05:16" | some perl/awk programming 
90900s

No need for awk, perl, or the like if you have either GNU's date or the AST tools from AT&T Labs-Research installed. Both date commands support something doing something like this:

echo $(( $( date +%s ) - $(date -d "Jun 12 21:05:16" +%s) ))

which subtracts the date given from the current time yielding seconds.

If you don't have either of these versions of date, and cannot install one, then you'll need to resort to something more complicated; thought I'd toss out an easy solution on the off chance that it will work for you.

You can try a variation of this perl script:

#!/usr/bin/perl -w
# Script: get_time_diff.pl
use Time::Local;

print "Enter day (1-31): ";
$day = <>;

print "Enter month (1-12): ";
$month = <>;
$month = $month - 1;

print "Enter year: ";
$year = <>;
$year = $year - 1900;

$time    = timelocal(0,0,0,$day,$month,$year);
$curtime = time;
$diff    = $curtime - $time;

print $diff . " seconds have passed since the date you entered.\n";

if ($diff > 0) {
  $diff = int($diff / 60 / 60 / 24);
  print $diff . " days have passed since the date you entered.\n";
} else {
  $diff = abs(int($diff / 60 / 60 / 24));
  print "There are " . $diff . " more days until the date you entered.\n";
}