Displaying both sensor value and the elapse time at the same time

I am displaying both sensor value and the elapse time at the same time . But i need not to constantly show the timing. Only when there is a value from the sensor then the time will show . Hence, im not sure how to edit my codes . Need anyone views . Thank you !
Here is the code


CountUpDownTimer T(UP, HIGH); // Default precision is HIGH, but you can change it to also be LOW

int sensorPinA0 = A0;

int sensorValue0= analogRead(sensorPinA0);

void setup()
  T.SetTimer(0,0,20);     //start at 1 minute (USE FOR: DOWN ONLY)
//  T.SetStopTime(0,0,30); // stop at 10 seconds (USE FOR: UP/DOWN)

void loop()
  T.Timer(); // run the timer
 // if (T.TimeHasChanged() ) // this prevents the time from being constantly shown.

  sensorValue0= analogRead(sensorPinA0);

  Serial.print("\t Sensor 0 :");
  Serial.print(" ");

You will get a value from the analogRead() each time you use it so how will you know

when there is a value from the sensor

Do you get a particular value (perhaps zero) when no sensor data is available ?

Do you mean that you want to show the time only when the sensor value changes ? If so, then save the value each time you read it and compare it with the subsequent reading. If it has changed, display the time and the reading. If you do this you will probably want to allow a range of values not to be considered as a change as the value returned may change a little each time it is read. If so, only display the time and reading if the value has changed by a significant amount.

This is example of the sensor values :

Sensor 0 : 0 Sensor 0 : 0 Sensor 0 : 0 Sensor 0 : 14 Sensor 0 : 123 Sensor 0 : 323 Sensor 0 : 234 Sensor 0 : 13 Sensor 0 : 21 Sensor 0 : 0 Sensor 0 : 0

The time will keep on elapsing. But it will display only when the sensor values is more than 0-15.

Hence expected output something like this :

Sensor 0 : 123 0:0:1:1001:1000553 Sensor 0 : 323 0:0:2:2003:2002001

Use the time library with an RTC to get the time. Or just use millis if you don't need real world time. Set up an if statement and when your sensor value is greater than 15, print the sensor value and then print the time.