Compare logged data on SD card to current reading - £25 for working answer

unixtime presumably returns an unsigned long integer. The %d format in sprintf implies an 'int' which on UNO/NANO/etc is a 16-bit integer.
Use %ld.
P.S. There is a warning message from the compiler about this - for example:

C:\Users\Peter\AppData\Local\Temp\arduino_modified_sketch_136698\sketch_jul18a.ino:11:45: warning: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t {aka long unsigned int}' [-Wformat=]

   sprintf(tmp,"Long integer warning %d\n",ul);

                                             ^

Pete