Example advise not using the Millis function.

Record and handle millis() rollover manually using an extra uint32_t? You’d then be good for 2^64 milliseconds or more than 584 million years.

PaulS:
Suppose that you want to do something every 60 days...

Yes, I know. That is why I wrote the "for you" in that sentence you quoted. I originally had written something about the time limit in there but decided that was just going to cause confusion since it clearly didn't apply for this application so I removed it before posting.

PaulS:
Suppose that you want to do something every 60 days...
Can you show me the easy code to do that, using millis()?

Sure!

const byte SensorPin = A0;    // select the input pin for the Soil moisture sensor


const unsigned long OneDayInterval = 24UL * 60UL * 60UL * 1000UL;


unsigned long StartTime;
unsigned DayCounter = 0;  // For intervals up to 65535 days (179 years)


void setup()
{
  Serial.begin(9600);
  StartTime = 0;
}


void loop()
{
  if (millis() - StartTime >= OneDayInterval)
  {
    StartTime += OneDayInterval;
    DayCounter++;
    if (DayCounter == 60)
    {
      DayCounter = 0;
      int sensorValue = analogRead(SensorPin);
      Serial.print("sensor = " );
      Serial.println(sensorValue);
    }
  }
}

just to be sure . the code that you write it hasent overflow problem. Do i undestastand correctly ?

The unsigned subtraction used to tell the difference between 2 times (call them start and end) is not affected by rollover between the 2 times except when the difference is more than the unsigned variables can count. Unsigned long milliseconds can count to 49.71-some days as the longest interval.

To make it simple, look at a round 12 hour clock. It is unsigned. How many hours between start at 10 and end at 4? Put the hour hand on 4 and then subtract 10 by moving the hand backwards 10 places and the hour hand points to 6 which is the number of hours between 10 and 4.

But you don't want to use the Arduinos with resonator for clock unless you want to correct it a few minutes every day. At least get or make one (you can with instructions available) with a crystal. Best thing for day to day timing is to use an RTC or other clock.

dataoikogarden:
just to be sure . the code that you write it hasent overflow problem. Do i undestastand correctly ?

Neither of the sketches I wrote have an overflow problem.
The first one (reply #16) measures in milliseconds and works for intervals up to 49 days.
The second (reply #22) measures in days and works for intervals up to 179 years.

We had one member whose name slips by me, he wrote beautiful code and did leave a 64-bit time library that uses unsigned long long (Arduino does have) to millis time what I figured as past the time when our sun goes red giant, 2 billion or so years from now.

Thank you very much for the reply. Have a noce day !

An RTC can be set up to make a pulse at chosen intervals, good for interrupt use.

When I time stamped logs it was with the system clock as an 8 char hex value (on the PC it was 32-bit Unix Seconds, on Arduino it was 32-bit millis, the 8 chars make a nice even left edge for the log) and then the event message. Some of the messages were point of sale info with time in them, others came from the video recorder and others from sensors in one job and NONE of the clocks were synchronized which didn't bother me at all as long as I had the system time to match device time messages I could show the time between any two log lines according to any of the clocks.
Your Arduino is less accurate than the RTC but making and processing RTC calls takes a good chunk of cycles while the Arduino drift over an hour is very small, perhaps less than the time to make an RTC time stamp.