An answer at answers.com quotes American Heritage Dictionary of Idioms to the effect that to not give someone the time of day means
Ignore someone, refuse to pay the slightest attention to someone, as in He's tried to be friendly but she won't give him the time of day. This expression, first recorded in 1864, alludes to refusing even to answer the question, "What time is it?"
By contrast, an answer at tywkiwdbi.blogspot.com says:
the expression goes far back beyond the time when people wore watches... In Shakespeare's day, the meaning was quite clear. "Good time of day" or "fair time of day" was a salutation just like "good morning" or "good evening"...We no longer greet people by saying "good time of day," but we still use the idea of giving such a greeting as a sign of favorable attention. In other words, refusing to give someone the time of day is thinking so little of him that you would not say hello to him on the street." (credit to Scribal Terror)
If tywkiwdbi and Scribal Terror are right, then the expression is rather older than the AHD Dictionary of Idioms said.
Edit: The BBC Learning English presentation “Not give someone the time of day” says:
Long ago, in Shakespeare's time, the phrase 'good time of day' was a greeting often used. These days we say 'good morning' [or 'good afternoon'] … So to say that you wouldn't give someone the time of day means you wouldn't want to greet them or say hello. So the saying means you refuse to give someone your attention.
As an example of the phrase used in Shakespeare's time, consider King Henry VI, part II, Act III, scene I, as Queen Margaret speaks:
Can you not see? or will ye not observe
The strangeness of his alter'd countenance?
...
We know the time since he was mild and affable,
...
But meet him now, and, be it in the morn,
When every one will give the time of day,
He knits his brow and shows an angry eye,
And passeth by with stiff unbowed knee,
Edit 2: Another example from Shakespeare (as pointed out by ΜετάEd's reference) is from King Richard III, Act I, scene III, when Buckingham says “Good time of day unto your royal grace!”. Note, Shakespeare is believed to have written both plays about 1591; he might or might not have put 16th-century speech into the mouths of 15th-century people. Henry VI was King of England and/or France at various times between 1422 and 1471, and Richard III from 1483 until his demise in 1485.
Tom Dalzell’s The Routledge Dictionary of Modern American Slang and Unconventional English says the word dukes for fists in “put up your dukes” was attested as early as 1859. Dalzell says that forks was slang for fingers, and suggests that forks became dukes by way of the rhyming slang “Duke of Yorks”.
Credence is lent to this theory by Albert Barrère and Charles Godfrey Leland’s 1890 edition of A Dictionary of Slang, Jargon & Cant, which attests the very similar slang expression “put up your forks” meaning to challenge to a fight. (To put one’s forks down, however, was to pick a pocket!)
More corroboration comes from the 1859 The Vulgar Tongue: a Glossary of Slang, Cant, and Flash Words and Phrases by “Ducange Anglicus” (a wonderful pseudonym which loosely translates as “English dictionary”). “Anglicus” attests the verb fork in the phrase “fork out the tin” meaning “hand out the money”, used in London between 1839 and 1859. (Fork out is surely cognate with today’s idiom fork over.) This puts fork at the right place and time to make it possible for Cockney rhyming slang to invoke the noble Duke of York exactly as suggested by Dalzell.
However, the intermediate phrase “put up your Duke of Yorks” is theoretical: not attested in any text of which I am aware, which still leaves open the possibility of some alternative origin for the term.
Best Answer
Many moons ago is an old-fashioned expression that means a long time ago. Moons refer to months (month derives from moon) and the expression meaning is just literal. According to Ngram its usage is from the 18th century. It appears the expression is just a popular/common way to refer to an ancient measure of time.
(www.bayjournal.com)
Month:
(Etymonline)