Philip was indeed on active service as a naval officer during the Second World War.
Probably the most dramatic aspect of his wartime experiences was his participation in the Battle of Cape Matapan, the relevant portion of which was a night action between units of the British and Italian fleets in 1940. His battle station was as a midshipman commanding a searchlight on the battleship HMS Valiant. His recollections of this experience, given several decades later in the forward to a book about the battle, were:
“I reported that I had a target in sight and was ordered to ‘open shutter’. The beam lit up a stationary cruiser and at this point all hell broke loose, as all our eight 15-inch guns, plus those of the flagship, plus HMS Barham’s, started firing at the stationary cruiser, which disappeared in an explosion and a cloud of smoke. I was then ordered to ‘train left’ and lit up another Italian cruiser, which was given the same treatment."
Philip was mentioned in dispatches for this service (one can't be certain whether an ordinary midshipman from a less distinguished family would have been) and received the Greek Cross of Valour as well.
Later in the war he saw action again during the invasion of Sicily, by which time he was a first lieutenant aboard the destroyer HMS Wallace. The ship was attacked at night by German aircraft, and Philip's contribution was to help throw together a decoy, made of smoke floats - an idea he described to one later interviewer as "a frightfully good wheeze" that drew off the enemy attack. According to one shipmate, Harry Hargreaves, who may have been over-stating the case:
“It had been marvellously quick thinking. Prince Philip saved our lives that night. I suppose there would have been a few survivors, but certainly the ship would have been sunk. He was always very courageous and resourceful.”
By the end of the war, Philip had been transferred to another destroyer, HMS Whelp, in the Pacific Theatre and was present in Tokyo Bay for the Japanese surrender.
Incidentally, while I am far from the royal family's biggest fan, and recall being highly sceptical that Prince Andrew would be placed in the line of fire during the Falklands conflict, it would seem his service as a helicopter pilot in that war was also moderately hazardous.
Source
JE Harrold, Dark Seas: The Battle of Cape Matapan
Given he was still a Danish and Greek prince at this point (both titles he would later renounce to marry) and given that his brothers-in-law were Nazi sympathisers, and especially given that the Princess Elizabeth was 14 years old in 1940, was Philip actually seen as her intended during the war? Or just an impoverished Greek prince with British connections?