The two-word any time is always the safer choice if you are writing for school or work or in any other formal context. If you do use the one-word form, anytime, make sure it is an adverb.
Dictionaries list the one-word anytime as an adverb meaning at any time, and they don’t assign it any other functions. But the word is also frequently used as a subordinating conjunction, synonymous with whenever and usually meaning every time that.
Anytime is a new word. Merriam-Webster’s dictionary lists 1926 as the year of its first known use (though earlier instances are easily found in historical Google searches). The Oxford English Dictionary doesn’t list it at all. Some sources say it is an Americanism, and while it’s true that the word is especially common in American publications, it is used throughout the English-speaking world.
There are a few situations in which any time should logically be two words. When it is embedded in the adverbial phrase at any time, it’s two words because at must be followed by a noun or a noun phrase, and anytime doesn’t work as a noun. It’s also two words in constructions like I don’t have any time to spare because any is an adjective modifying the noun time, and the words together don’t directly modify anything.
If you have trouble with anytime and any time, the easy solution is to always make it two words. Garner’s Modern American Usage calls the newly formed contraction a casualism (and indeed many of the examples we find in news sources are in quoted speech), and the fact that it is not listed in the OED or in other British dictionaries shows that it has yet to gain full acceptance. No one questions any time.
Both anytime and any time can function adverbially—for example:
His secret deregulation report recommended companies be free to sack anyone anytime and cut maternity rights. [Guardian]
If you were born any time since 1998 you have no problems. [Sydney Morning Herald]
In this environment, the financial industry is unlikely to be minting new billionaires anytime soon. [New York Times Dealbook]
For these fashion-loving souls, taking one’s clothes off any time before August is uncouth. [Independent]
In these examples, anytime operates more like a conjunction because it introduces a dependent clause:
Anytime Collins is a guest of the ambassador … he ends up accompanying him on the piano. [Irish Times]
[A]nytime you own a phone and use it in any way, it is irrefutable proof that you don’t have a concussion. [The Province]
But any time is also used the same way—for example:
Any time you negatively affect the future revenues by mortgaging the future of a team, you are endangering its very survival. [Scotsman]
And of course, any time Wallace threw to a videotape, it was over. [AV Club]
And of course, any time also works as a nonadverbial phrase—for example:
So far this year, the average audience for 11 of the 15 most-watched cable channels at any time of day has fallen from a year earlier. [Wall Street Journal]
Nor does Obama have any time for the rigidities of the so-called “Bush Doctrine” that emerged from the ashes of 9/11. [London Evening Standard]