About the closest thing to an official answer to your question that I know of is this geocaching.com blog post, which says (boldface original):
Caches can be logged online as “Found” after the geocacher has visited the coordinates and signed the logbook.
Now, technically, this doesn't necessarily mean that, once you've completed both requirements, you couldn't backdate your find to an earlier date. But the blog post does go on to say that:
- When logging a cache online, use the date you attempted the cache. This helps to provide a more accurate view of the cache’s current condition.
(The reason for using the word "attempted" instead of "found" here is presumably because this guideline is meant to apply to all types of online log entries, including "Did Not Find" and "Needs Maintenance" logs.)
So, following the guidelines set out in this blog post:
You should not log the cache as found online before you actually sign the physical logbook.
(You could, however, post a "Note" or a "Did Not Find" log describing your earlier visit if you want. Many cache owners like to hear about people visiting their cache even if they fail to find and/or sign it.)
Once you do revisit the cache and sign the logbook, you may log it as found online. When doing so, you should probably use the date on which you sign the physical logbook.
It's also possible that, if you do post a note saying that you found the cache but couldn't sign the logbook, the cache owner might contact you and suggest that you just log the cache as found, even though it's technically against the rules. In that case, it's up to you whether you want to do that or not. Some cache owners are quite lenient about such "found but couldn't sign" logs, some are not.
(Personally, I neither encourage nor discourage them on my own caches, but I do try to be strict about my own finds, and will post a note instead if I e.g. forget to bring my pen. But I feel that, if a cacher personally considers something a find, that's generally fine with me. I might be stricter about it if I had any caches where getting access to the logbook was particularly difficult by design.)
In practice, the date of the online log only matters for two purposes:
It tells the cache owner (and anyone else browsing the online logs) about the status of the cache: if you log the cache as found on a particular date, you're communicating that the cache was in place, intact and able to be successfully logged on that date. This could be useful information for the cache owner and/or for other potential seekers, e.g. if someone had earlier reported the cache as potentially missing.
Some challenge caches may have additional logging requirements that require you to find other caches on specific dates (or e.g. to maintain a streak with at least one cache found per day for a certain number of days).
The challenge part is what sometimes gets people worked up over things like log dates,* since some of those challenges can be genuinely hard, and there can be a certain temptation to "cheat" (e.g. fudging the log date on a cache found just after midnight to avoid breaking a six-month streak) even though, ultimately, it's just a voluntary challenge in a non-competitive game.
If you're not planning on doing any hard challenge caches, there's not much point in being strict about log dates. Just use whichever date seems the most appropriate. But I'd generally still suggest using the date when you actually signed the physical log (and which you presumably also wrote in the physical logbook) unless you have some particularly good reason to do otherwise.** It gives more accurate information to the cache owner, and if you do decide to start doing challenges later, you won't have to worry about whether your old logs really qualify or not.
*) What really tends to get people worked up is when an inactive cache owner suddenly decides to go through their old logs and delete any that they deem invalid, e.g. because the visitor didn't sign the right logbook, retroactively breaking old streaks etc. Don't be that person. While as a cache owner you do have the right to delete invalid logs, please don't do it without warning unless the log is obviously completely bogus. At least message the person who left the log and give them a chance to fix their mistake.
**) As a personal anecdote, I've "misdated" a find log once (that I know of): one of the first caches I found was logged as a group, but the person signing the log forgot to include my nickname. The cache owner contacted me about this later, after not finding my name in the physical log, so I went back and added my name to the logbook but didn't change the original log date, even though technically I'd only completed the logging requirements once my name was actually in the book. I think I did post a note about the revisit, though.