How to change color of an object based on camera's FOV?

Hi, I’m a noob in unity and wanted to know how can we change the color of the object if the object is in the camera’s FOV for 5 sec or less!

Use isVisible. To time within 5 seconds create two float variables, when isVisible is true set the first float at Time.time and when is visible is false set the second float at Time.time and if float2 - float1 is less than 5 change the color.

float startTime, endTime;

void Update(){
        if(startTime == 0){
            startTime = Time.time;
        if(startTime != 0){
            endTime = Time.time;
            if(endTime - startTime < 5){
                //change color
            //reset startTime to 0 to stop a loop from happening.
            startTime = 0;