How can I start millis() only when a signal is received?

Hi, I know this is a very basic question but I'm very new to arduino and was having trouble finding an answer to this question that I could clearly understand.

I have the following code:

int sensorPin = A0;
int sensorValue = 0;

// Values needs to be changed for the ipad display
int black = 940;
int white = 820;
char _switch = 'n';

unsigned long time;

void setup() {
  Serial.begin(19200);
}

void loop() {
  time = millis();
  sensorValue = analogRead(sensorPin);
  switch (_switch){
    case 'n':
      if (sensorValue < 820){
        Serial.println(time);
        _switch = 'g';
        break;
      }
    case 'g':
      if (sensorValue > 920){
        _switch = 'n';
        break;
      }
    
  }
}

This is hooked up to a photoresistor, and I want to print the time it records a white flash from a monitor.

I only want millis() to start counting when it receives a command from a C# script I am running, and I'm not sure how best to go about this.

I am guessing I could use something like the following:

if (Serial.available() > 0) {
    startTimer = Serial.read();
    if (startTimer == 1) {
        // then the rest of my loop here
    }
}

Where I would initialize startTime as 0, then send a 1 when I want millis() to start. However, this doesn't work I think because I am not constantly sending a signal to the arduino, it's only a single pulse, so I can't re-enter the if statement after the initial input.

So what would be the best way to go about this?

**edit: **
Ah so I realized pretty much immediately I can just not nest the second if statement in the first and it should work how I want it to, as posted below. Now I'm wondering if this is best practice, or if there is a better and simpler way to accomplish what I am trying to do.

if (Serial.available() > 0) {
    startTimer = Serial.read();
}

if (startTimer == 1) {
    // then the rest of my loop here
}

You are not thinking the right way about this.

You don't 'start' millis when you need to start a timer, millis is always running in the background, just like your clock at home. When you need to know the time an event happened, you save the current value of millis() to a variable.

When you want to know how much time has passed since that event, you do the current millis() - timeRemembered, just like you would look at your clock and see the difference in time between a start time and now.