LDR Sensor multiple read value question

Can you tell me how to do 1 thing in it please? Its an LDR sensor circuit which opens a mag lock but I want it to read the value a number of time, say for 3 seconds before opening the lock. This will prevent anyone covering the sensor for a shorter time from releasing the lock by mistake. Thanks.

int LDR = 1; //analog pin to which LDR is connected, here we set it to 0 so it means A0
int LDRValue = 10; //that’s a variable to store LDR values
int light_sensitivity = 36; //This is the approx value of light surrounding your LDR

void setup()
{
Serial.begin(9600); //start the serial monitor with 9600 buad
pinMode(3, OUTPUT);
//we mostly use 13 because there is already a built in yellow LED in arduino which shows output when 13 pin is enabled
}

void loop()
{
LDRValue = analogRead(LDR); //reads the ldr’s value through LDR
Serial.println(LDRValue); //prints the LDR values to serial monitor
delay(0); //This is the speed by which LDR sends value to arduino

if (LDRValue < light_sensitivity)
{
digitalWrite(3, HIGH);
}
else
{
digitalWrite(3, LOW);
}
delay(0);
}

Can you tell me how to do 1 thing in it please?

unsigned long startReading = millis();
unsigned long timeToRead = 3000; // Three seconds

bool itsDarkInHere = false;
while(millis() - startReading <= timeToRead)
{
   int LDRValue = analogRead(LDR);
   if(LDRValue > light_sensitivity)
   {
      itsDarkInHere = false;
      break;
   }
   else
      itsDarkInHere = true;
}

// Now, base the decision on itsDarkInHere, not LDRValue

This doesnt seem to be working, Can you post all of the code in case I'm missing something simple? Thanks

This doesnt seem to be working,

You've incorporated the idea into a sketch that you didn't post. The code that you didn't post does something that you didn't describe. You expect it to do something that you did not describe.

All we know at this point is that your expectations are wrong.

const int LDR = A1;     //analog pin to which LDR is connected, here we set it to 0 so it means A0
const int light_sensitivity = 36;    //This is the approx value of light surrounding your LDR
const int LockPin = 3;
unsigned long LastLightTime = 0;
const unsigned long MINIMUM_DARK_TIME = 5UL * 1000UL;

void setup() {
  Serial.begin(9600);          //start the serial monitor with 9600 buad
  pinMode(LockPin, OUTPUT);
  //we mostly use 13 because there is already a built in yellow LED in arduino which shows output when 13 pin is enabled
}

void loop() {
  int LDRValue = analogRead(LDR);      //reads the ldr’s value through LDR
  Serial.println(LDRValue);       //prints the LDR values to serial monitor

  if (LDRValue < light_sensitivity && millis() - LastLightTime > MINIMUM_DARK_TIME) {
    digitalWrite(LockPin, HIGH);  // Open?
  }
  else {
    digitalWrite(LockPin, LOW);
    LastLightTime = millis();
  }
}