I initially set the date/time at set up. The cam is on when the car is on. Other times it’s off. How does it not lose the time?
The same way plenty of non-automotive devices keep the time (and plenty of other stuff). Your dashcam (assuming it’s original equipment) is never really “off.” It may not be recording video, but it’s still plugged into the car’s electrical system, which is never really “off.” It’s powered by the car’s battery, even when the car is switched off. So either it’s still keeping time, or, when the camera is recording video, it’s checking the time with some other chip in the car that’s running a clock.
It’s a very, very small power drain, and unlikely to kill your battery, so you’ll never notice it.
Some electronics also have small batteries inside to maintain power for memory even when the devices aren’t directly connected to a power source.
I wouldn’t be shocked if you disconnected the dashcam completely and it still knows the current time/date after being plugged back in.
Yeah, it’s usually an onboard backup battery or supercapacitor that maintains the real time clock and ensures that the current file is written cleanly even if the power is abruptly lost (which can happen in a collision incident anyway).
The electrical supply for a dashcam normally is one that receives no power when the ignition is turned off - this is how the camera knows to start and stop recording in many cases.
Back in the day I had an older iPod (3rd gen with an actual hard drive inside) that I used in the car on long trips. Its battery was getting pretty old so I’d need to leave it plugged into a cigarette lighter/USB charger. At least twice I’d left it and the car sitting for nearly a week and had trouble starting the car after that. I stopped leaving it plugged unattended and never had an issue after that. Maybe the starting trouble was a fluke/coincidence, weak car battery, winter weather etc., but the iPod was definitely sipping on the car battery the whole time regardless.
Most cigarette lighter ports require the ignition to be on to have power, but not all of them. One of our cars explicitly has two ports, one marked with a “battery” icon and one with an “engine” icon. The battery one is always hot, the engine one only when the ignition is on.
Did a lot of car radio installs back before plug-n-play wire harnesses were a thing and you had to match up the wires on your own. They all had a constant power wire to keep things like the clock and memory presets intact and a separate power wire that was live only when the ignition was on.
A wristwatch can keep the day/time current for literally decades, using only a battery small enough to fit into, well, a wristwatch. It takes a really, really trivial amount of power to do that.
The likely answers have been given already, but here’s another: many dashcams have small GPS units in them. GPS provides a very accurate time. It would just need to remember the time zone, which can be in non-volatile memory (like flash).
GPS does indeed do that but I doubt it is keeping the time on these. GPS signal lock takes a bit when first starting, and works poorly in parking garages and the like.
Increasingly supercaps are used for this kind of thing. They’re cheaper, lighter and, mainly, batteries can have some restrictions when it comes to shipping. My own dashcam uses a supercap and loses the T&D if not turned on after a few days.