BitcoinTalk
Difficulty

View Satoshi only

External link

http://nullvoid.org/bitcoin/difficultiez.php

Code:
<?
header("Content-type: text/html");
require_once 'jsonRPCClient.php';
$data=new jsonRPCClient('http://127.0.0.1:8332');
$blockcount = $data->getblockcount();
$now = date("U");
$blockfile = "blockdata";
$data = file($blockfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); array_pop($data);
?><html>
 <head>
  <meta http-equiv="refresh" content="100000">
 </head>
 <body>
  <pre>
<?
function humantime($secs) {
if ($secs<0) return false;
$m = (int)($secs / 60); $s = $secs % 60; $s = ($s <= 9) ? "0$s" : $s;
$h = (int)($m / 60); $m = $m % 60; $m = ($m <= 9) ? "0$m" : $m;
$d = (int)($h / 24); $h = $h % 24; $h = ($h <= 9) ? "0$h" : $h;
$d = ($d <= 9) ? "0$d" : $d;
return $d."d $h:$m:$s";
}

// Converted from ArtForz's python code http://bitcointalk.org/index.php?topic=464.msg4080#msg4080
function uint256_from_compact($c) {
$nbytes = ($c >> 24) & 0xFF;
return bcmul($c & 0xFFFFFF,bcpow(2,8 * ($nbytes - 3)));
}

$tblock = 0;
$nTargetTimespan = 60 * 60 * 24 * 14;
bcscale(256);
foreach ($data as $line) {
$blocks = strtok($line, " ");
$date = strtok(" ");
$avghash = strtok(" ");
$bits = strtok(" ");
if ($blocks == 0 || $blocks == $tblock) {
$tblock = $blocks + 2016;
$blocknum = str_repeat(" ", 6 - strlen($blocks)).$blocks;
echo "Block $blocknum was generated at $date (".date("r", $date).")";
if ($blocks != 0) {
$intervalnum = $date - $lastdate;
$interval = str_repeat(" ", 9 - strlen($intervalnum)).$intervalnum;
echo "    $interval seconds interval (".humantime($intervalnum).")";
echo "   Difficulty: ".bcdiv(bcdiv(bcmul(uint256_from_compact(0x1D00FFFF),1000), uint256_from_compact($bits)), 1000);
$lastdate = $date;
}
echo "<br>";
}
}
?>
  </pre>
 </body>
</html>
nice precision! latest difficulty = 244.213223092375323881335701184896212407930361873708113773326734402748260502489 1554339282075169582811726687822061777635447902413461818393548574922122914786456 6654051064077556842993973623686279076537890477160907158869253835628402573582928 17840402922938076799906
 
Hehe, thanks. I could provide more accurate precision, but I think that is good enough.
I'm just thankful the difficulty isn't 244.213223092375323881335701184896212407930361873708113773326734402748260502489 1554339282075169582811726687822061777635447902413461818393548574922122914786456 6654051064077556842993973623686279076537890477160907158869253835628402573582928 17840402922938076799907

Just imagine how hard it would be to win a block then!!!!!
Actually, calculating with another digit comes out to 244.213223092375323881335701184896212407930361873708113773326734402748260502489 1554339282075169582811726687822061777635447902413461818393548574922122914786456 6654051064077556842993973623686279076537890477160907158869253835628402573582928 178404029229380767999068 and thus could be rounded up to the value you suggested Insti.
It appears that block 70718 was found two hours in the future and followed with block 70719 being found about two hours in the past (from the future date of previous block).

Code:
-7017 seconds to find block 70719
  8153 seconds to find block 70718
    49 seconds to find block 70717
   524 seconds to find block 70716

Code:
block timestamp
70715 1280275621
70716 1280276145
70717 1280276194
70718 1280284347
70719 1280277330

This doesn't seem to have any effect on things so much other than providing a kind of inaccurate depiction of statistical results every now and then (when a block is claimed to be from the future or the past), however what would happen if either the first or second (whichever one triggers new difficulty being established) of a new set of 2016 blocks is generated  to have a timestamp 2+ weeks in the past or the future?  If in the past, I presume according to the code in main.cpp: GetNextWorkRequired function that the lowest accepted interval is 3.5 days.  And if in the future I presume according to the code the lowest accepted interval is 56 days.
You were looking at the wrong code.  Here's the code that applies:

Code:
bool CBlock::CheckBlock() const
{
...
    // Check timestamp
    if (nTime > GetAdjustedTime() + 2 * 60 * 60)
        return error("CheckBlock() : block timestamp too far in the future");
...

bool CBlock::AcceptBlock()
{
   ...
    // Check timestamp against prev
    if (nTime <= pindexPrev->GetMedianTimePast())
        return error("AcceptBlock() : block's timestamp is too early");

The timestamp is limited to up to 2 hours in the future.  It can be earlier than the previous block, but it must be greater than the median of the last 11 blocks.  The reason for doing it that way is so the time can get corrected in the next block if the previous block had the time too far in the future, like what happened.