This is how I do probability per hash:

$hash=$hextarget;

$hash=strtoupper($hash);

$probability=`echo "obase=10;ibase=16;scale=37;$hash/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |bc`;

(The tickmarks execute the command on the shell.)

Then you do 1/$probability to get average number of hashes. Divide this by the number of hashes you're getting per second to get the number of seconds.

You can calculate the target like this:

26959535291011309493156476344723991336010898738574164086137773096960/difficulty

"Difficulty" is the number returned by getDifficulty. (The huge number is the maximum target, which getDifficulty is based on.) This calculation is not exact.

I search debug.log to get the target, but the result of the last retarget seems to be less accurate than the calculation above. I'm not sure why this is. Maybe the code changed. (Edit: I now

*think* that this is just an artifact from the "nBits" decompression.)