light duration on or off time measurement

im working on a project consisting of a motion sensor, which once it detects motion a relay will be on and in return an led will be on. everything works fine, but all is left is to measure the on/off time when led is off and when led is on and display it on an LCD. Im using miilis() but its not resetting the time continues to count.
is there any way to measure time for each case (ON/OFF) separately using millis() or any other method?

Here is my code

#include <LiquidCrystal.h> // include the library code:

int sensor_pin = 8; // Initialized the pin for motion sensor
//int relay_pin = 9;  // Initialized the pin for relay module
int output;   // Variable to store the output state of motion sensor

// On and Off Times (as int, max=32secs)
const unsigned int onTime = 1000;
const unsigned int offTime = 500;

// Interval is how long we wait
unsigned long interval = onTime;

// Tracks the last time event fired
unsigned long previousMillis=0;

// Used to track if relay should be on or off
boolean relay_pin = true;
 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins

void setup(){
  lcd.begin(16, 2); // set up the LCD's number of columns and rows
  
  Serial.begin(9600);
  pinMode(sensor_pin, INPUT);   // Declared motion sensor pin as Input
  pinMode(relay_pin, OUTPUT);   // Declared relay module pin as Output pin
  // Make the relay module initial state as low, Relay works opposite
    pinMode(13, OUTPUT);         //Set Pin13 as output
  digitalWrite(13, HIGH);  
  digitalWrite(relay_pin, LOW); 
 // set the cursor to column 0, line 1
  
}
void loop(){
  // Read the output state of motion sensor
  output = digitalRead(sensor_pin);
  
  // If output is High
  if(output == 1){
    digitalWrite(relay_pin, HIGH);
      lcd.setCursor(0, 0);
    lcd.print("LIGHT IS ONN"); // Print a message to the LCD.
      

  // print the number of seconds since reset:
  
  //lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  //lcd.print( millis() / 1000);
  
  }
  
  // If output is LOW
  else
  {
    digitalWrite(relay_pin, LOW);
      lcd.setCursor(0, 0);
    lcd.print("LIGHT IS OFF"); // Print a message to the LCD.
    

  // print the number of seconds since reset:
  
     //lcd.setCursor(0, 1); 

  // print the number of seconds since reset:
  //lcd.print(millis() / 1000);
   
  }
    
  Serial.println(output);
  delay(50);
  digitalWrite(13, relay_pin);
  // Grab snapshot of current time, this keeps all timing
  // consistent, regardless of how much code is inside the next if-statement
  //unsigned long currentMillis = millis();
 
  // Grab snapshot of current time, this keeps all timing
 long currentMillis = millis();

  // Compare to previous capture to see if enough time has passed
  if ((unsigned long)(currentMillis - previousMillis) >= interval)
  {
    // Change wait interval, based on current relay state
    if (relay_pin) 
    {
      // Relay is currently on, set time to stay off
      interval = offTime;
      // print the number of seconds since reset:
     lcd.setCursor(0, 1); 
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
    } 
    else 
    {
      // Relay is currently off, set time to stay on
      interval = onTime;
      // print the number of seconds since reset:
     lcd.setCursor(0, 1); 
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
    }
    // Toggle the relay's state
    relay_pin = !(relay_pin);
    // Save the current time to compare "later"
    previousMillis = currentMillis;
  }
}

Why have you posted this again ?

Duplicate of independent on and off timer - Programming Questions - Arduino Forum

Not exactly sure what you are looking for, but this might get you closer... (untested)

#include <LiquidCrystal.h> // include the library code:

int sensor_pin = 8; // Initialized the pin for motion sensor
int relay_pin = 9;  // Initialized the pin for relay module
int output;   // Variable to store the output state of motion sensor

// On and Off Times (as int, max=32secs)
const unsigned long onTime = 1000;
const unsigned long offTime = 500;

// Interval is how long we wait
unsigned long interval = onTime;

// Tracks the last time event fired
unsigned long startTime = 0;


// Used to track if relay should be on or off
byte currentRelayState = LOW;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins

void setup() {
  lcd.begin(16, 2); // set up the LCD's number of columns and rows

  Serial.begin(9600);
  pinMode(sensor_pin, INPUT);   // Declared motion sensor pin as Input
  pinMode(relay_pin, OUTPUT);   // Declared relay module pin as Output pin
  // Make the relay module initial state as low, Relay works opposite
  pinMode(13, OUTPUT);         //Set Pin13 as output
  digitalWrite(13, HIGH);
  digitalWrite(relay_pin, LOW);
}


void loop() {
  if ( interval ) {
    // we are waiting so check if enough time has elapsed
    if ((millis() - startTime) >= interval) {
      if (currentRelayState == HIGH) {
        // Relay is currently on, so turn off and set time to stay off
        interval = offTime;
        startTime = millis();
        currentRelayState = LOW;
        digitalWrite(relay_pin, currentRelayState);
        lcd.clear();
        lcd.print("LIGHT IS OFF"); // Print a message to the LCD.
      }
      else {
        // relay is off and offTime has expired so we are ready to detect motion again
        interval = 0;
      }
    }
    else {
      // still waiting so display elasped time
      lcd.setCursor(0, 1);
      lcd.print((millis() - startTime) / 1000);
    }
  }
  return;


  output = digitalRead(sensor_pin); // Read the output state of motion sensor

  if (output == HIGH && currentRelayState == LOW) {
    // If output is High but relay is off, we just detected motion so deal with it
    currentRelayState = HIGH;
    digitalWrite(relay_pin, currentRelayState);
    lcd.clear();
    lcd.print("LIGHT IS ON"); // Print a message to the LCD.
    startTime = millis();
    interval = onTime;
  }
  else if ( output == HIGH && currentRelayState == HIGH ) {
    // motion detected but relay is already on
    // not sure what to do?? reset timer maybe?
  }
}