# Difficulty and timestamp in beta

**URL:** <https://forum.zcashcommunity.com/t/difficulty-and-timestamp-in-beta/1685>\
**Category:** Mining\
**Created:** [September 12, 2016, 6:22pm UTC](https://forum.zcashcommunity.com/t/difficulty-and-timestamp-in-beta/1685 "2016-09-12T18:22:33Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![zawy](https://sea2.discourse-cdn.com/zcash/user_avatar/forum.zcashcommunity.com/zawy/32/11892_2.png) [@zawy](https://forum.zcashcommunity.com/u/zawy)\
**Post date:** [September 12, 2016, 11:20pm UTC](https://forum.zcashcommunity.com/t/difficulty-and-timestamp-in-beta/1685/7 "2016-09-12T23:20:38Z")

</div>

This is a perl script that will parse your debug.log file to get hash IDs as inputs for zcash-cli to get difficulty for your own block explorer. If log2\_work in debug.log has some conversion factor to difficulty, it could get by with just the debug file and be a lot faster. Debug.log will include canceled blocks, showing something block explorer doesn’t. It’s an ugly method, but I didn’t know how else to get blocknum, time, and difficulty. Save as a file in the folder above zcash and run with perl filename.

```
open (F,"<.zcash/testnet3/debug.log"); @a=<F>; close F;

foreach $a (@a) {
   if ($a=~/.+best=([^]+).+height=(\d+).+date=\d\d\d\d-\d\d-(\d\d) (\d\d):(\d\d):(\d\d).+/) {
  $block=$2;
  $secs=$3*24*3600+$4*3600+$5*60+$6;
  $info=`./zcash/src/zcash-cli getblock $1`; # 1 is hash
  $info=~m/"difficulty" : (\d+)/sg;  
  $diff=$1;
  $sum=$thissecs;
  $thissecs=$secs-$lastsecs;
  $sum+=$thissecs;
  if ($sum/300 < .22 or $sum/500 > 2.3) { $anomoly=" ***"; }
  $blocks[$block]="$block\t$secs\t$thissecs\t$diff\t$anomoly\n";
  $anomoly="";
  $lastsecs=$secs;
  $check = 'yes';
  }
}
open (F,">difficulty.txt"); print F @blocks; close F;
exit; 

```

To check if the reported timestamps from above are realistic, run the following bash program 24 hr to record when blocks come into your node. [https://forum.zcashcommunity.com/t/somebody-already-has-a-gpu-rig/1410/13](https://forum.zcashcommunity.com/t/somebody-already-has-a-gpu-rig/1410/13)

Use my code at your own risk.

---

_[View the full topic](https://forum.zcashcommunity.com/t/difficulty-and-timestamp-in-beta/1685)._
