Holden's adventures take place in December, starting on "the Saturday of the football game with Saxon Hall" (2). So it's early-to-mid December (Holden says many times that it is "close to Christmas". We don't know the exact date, but that's approximately the time period that his adventures on his own in New York occur.
At the end of the book the time is not specifically noted. We do know, however, that Holden refers to going to another school "next fall" (213), so we can assume that the time that he is in a convalescent hospital (or perhaps a psychiatric ward, as Holden mentions a "psychoanalyst", Ibid) during the following spring or summer. It's possible an entire year has past, but the tone that Holden employs does not imply that that amount of time has elapsed. These are events which have happened in the recent past: within the past few months.
As for his purpose, Holden says at the beginning "If you really want to hear about it...." (1), as if he is talking to someone who does want to know the events that lead up to his illness and (implied) nervous breakdown. We can consider that possibly Holden is talking to a psychotherapist or other kind of doctor. Or, maybe, to a friend, or family member -- but the completeness of the story leads one to think that it is reproduced for analysis, as one might do for a therapist of some kind.
Of couse, this is novel and not a transcript of therapy sessions between a patient and his doctor. So the "purpose", which is not stated, is author's views about life and, specifically, the pressures put on adolescents. This has been extensively analyzed in the literature written about this book, and there are many valid interpretations. Holden is a voluble critic of all the institutions, customs, and people of his world -- and critical of himself in addition. He lives some of the things he hates the most, such as being "phony" when he admits that he is "the most terrific liar you saw in your life" (16). Obviously, Holden is deeply conflicted, and, possibly, on the verge of being mentally ill. His critique of the world of his time is one of the outsider, but he is part of the elite world of prep schools and fancy apartment houses and families with live-in maids. He is a profound contradiction, which is perhaps a comment on the world of his time (1940s New York) in itself.
Source: Salinger, J. D. The Catcher in the Rye (1951). New York: Little, Brown, and Co., 1991.