Car starts sometimes

I have a 1994 nissan altima. when i first start my car it will start. If i go to a place no matter how long a drive is, if i turn it off and i come back within five minutes my car wont start back up. it will just crank, and continue cranking. I than tried to turn it on after about 8 hours and it will start. I need help. I dont know if its the alternator or the starter, pretty much i have no idea what it is. can someone please help me. Im desperate. My car is manual.

If its cranking over just fine then you can cross the alternator & starter off of the list (unless it is a weak crank).

The next time this happens, hold the gas pedal firm to the floor while you turn the key and then let up if it fires up. If that gets it going then you assume the car is getting flooded while it sits probably from either leaking fuel injectors or a leaking fuel pressure regulator. Do you ever get whiff of gas while its not starting?

If that doesn’t seem to help then the next thing to do is carry a spark tester and some starting fluid with you. When it won’t start use the spark tester to see whether you are getting spark. If you are, then give a shot of starting fluid into the intake & if that gets it to fire even a little bit then you know its a lack of fuel issue.

Is the check engine light on?

It would also be helpful to know about maintenance. How old are plugs & wires? Fuel & air filters?

well it does not crank like it wants to start. if i turn the key over than it will just make a noise but not a cranking noise.

Well when you typed this in your original post: "it will just crank, and continue cranking. what did you mean?

Cranking is when you turn the key and the car revs over and over. This does not mean that it starts - its just going RR…RR…RR…RR over & over but never gets running.

You can use “fire up” to refer to the car starting and running.

So clarify.

it will go RR… RR… RR… than that will stop and it will make a soung like GRRRRRRR. like its grinding some gears. than i stop and i turn the key again and it will do the same thing.

sounds like starter or battery. more so starter since it does it when warmed up.
many auto parts stores will do the test for free. most shops will charge a nominal fee. either way have the battery and starting system tested

Does the car need to be off for that test? Is there a way that i can do that myself?

it will just make a noise but not a cranking noise. <— that sounds like maybe the starter is spinning but not engaging

To have the battery & charging system checked you just take it to an auto parts store where they’ll check it for free. You can’t do it - it requires a chunk of equipment.

To have the starter checked it has to be removed from the vehicle. But long before you go there, the cable connections at the battery & starter should just be removed, cleaned up really well & reinstalled wrench tight.