Extend ESP8266 12 F Deep Sleep Time
All they are suggesting is that you keep a counter in non-volatile memory so that you can keep track of how many times the ESP has woken up.

Sometimes you want to know if it's the very first time the application has run, so that you can do things you'd only want to do on the first boot. You can use a Boolean flag for this purpose. If you find out that you don't need that you can remove it from my example. Please note that I did not compile nor test this code, it could have errors and is meant purely as an example to get you started on a solution. Hope it helps :)

// NVM Data
#define RTCMemOffset 10 // arbitrary location
#define MAGIC_NUMBER 55 // used to know if the memory is good and been written to 

struct
{
    int wakeCount;
    bool bFirstTime;
    int magicNumber;
} nvmData;

nvmData sleepMemory;

bool bDoneSleeping;

void setup()
{
    /* Woke up and entered setup */
    bDoneSleeping = false;

    if(rtcUserMemoryRead((uint32_t)RTCMemOffset, (uint32_t*) &amp;sleepMemory, sizeof(sleepMemory)))
    {
        if(sleepMemory.magicNumber != MAGIC_NUMBER) // memory got corrupt or this is the first time
        {
            sleepMemory.bFirstTime = true;
            sleepMemory.magicNumber = MAGIC_NUMBER;
            sleepMemory.wakeCount = 0;
        }
        else
        {
            sleepMemory.wakeCount += 1; // incrememnt the sleep counter
            sleepMemory.bFirstTime = false;
        }

        if(sleepMemory.wakeCount &gt;= 4) // reset the counter and do whatever else you need to do since 4 hours have passed
        {
            sleepMemory.wakeCount = 0;
            bDoneSleeping = true;
        }   

        rtcUserMemoryWrite((uint32_t)RTCMemOffset, (uint32_t*) &amp;sleepMemory, sizeof(sleepMemory)); // write the new values to memory
    }

    if(bDoneSleeping)
    {
         // Perform tasks
    }
    else
        // Go back to sleep
}