WakaTime is good for this, as it automatically groups into projects based on git repo.
Shameless plug follows:
timelyapp.com is similar to WakaTime, except it keeps track of _all_ the programs you use on the desktop, and for how long (MacOS/Windows only). Timely also tracks when you leave/arrive at work/home/other locations (GPS, requires mobile app). We can't claim offline mode, but all tracked "memories" are 100% your-eyes-only.
Timely is a time tracker specifically built for people who are bad at remembering what they worked on/don't log hours frequently. Sice Timely's "memories" are recorded to-the-minute, you can easily log accurate timesheets, even if you only do so once a month.
(Disclaimer: I work on Timely)