Hamlet says "time is out of joint" in Act I, scene 5, expressing his idea that his world is not sane and that things are not as they should be. In this scene, the ghost of King Hamlet asks Hamlet to avenge his murder by killing Claudius but leaving Gertrude, Hamlet's mother, alone. Hamlet says earlier in the scene, "There are more things in heaven and earth, Horatio, / Than are dreamt of in your philosophy" (I.5.169-170). In other words, the news that his own uncle has killed his father has made Hamlet realize that the world is a big and confusing place, as he tells Horatio, far more complicated than Hamlet had earlier imagined. He is in a state of shock.
At the end of the scene, Hamlet says, "The time is out of joint. O cursèd spite, / That ever I was born to set it right!" (I.5.190-191). Again, this means that Hamlet knows now that his world is not right. If time is not right, then nothing in the world is working correctly. He curses the ghost that came to him to tell him the truth about his father's murder, and he rues that he has to make the situation "right," meaning that he has to murder Claudius to avenge his father's murder.