temps is masculine (weather, time, days, stroke)
fois is feminine (times, occasion)
I think you can tell the difference from the following phrases:
quel temps fait-il? (what is the weather like?)
le bon vieux temps (the good old days)
en temps de guerre in wartime (during wartime)
un moteur à deux temps (a two-stroke engine)
une fois (once); deux fois (twice); trois/quatre fois (three/four times);
une fois pour toutes (once and for all); encore une fois (once again)
hope it can be helpful^^