Start time only when Sensor Val >0

Yes, millis() is the time in milliseconds since the Arduino was powered up or reset. So what ? You know when power was detected and when it stopped being detected so you can calculate how long it was on or off by subtracting one time from the other.