A California teenager has shared the incredible story of how he survived being stranded for 30 hours in the mountains of Utah in sub-freezing temperatures and waist-deep snow.

Nicolas Stacy-Alcantara, a 17-year-old high school student from Fresno, said he was visiting his ex-girlfriend near Salt Lake City last week when he decided to go for a day-long hike alone with plans to return in time for dinner.

2 TEEN SNOWBOARDERS LOST IN CANADIAN BACKCOUNTRY BURNED HOMEWORK TO SURVIVE, OFFICIALS SAY

He had packed six peanut butter and jelly sandwiches and 40 ounces of water before setting off.

Stacy-Alcantara said the weather had been relatively mild when he began his planned route from Millcreek Canyon to Park City, but by late afternoon the temperature dipped and snow began to fall.

The weather forced Stacy-Alcantara to stop his journey. His cellphone had no service and his feet began to freeze.

I didn’t want PB&J to be my last meal. — Nicolas Stacy-Alcantara, 17-year-old hiker

Stranded in the wilderness, he dug a snow cave beneath a tree to take cover from the elements. He rubbed his hands against his chest to keep the blood flowing.

“I knew my chest was more important than my feet," he told reporters Wednesday at University of Utah Hospital, according to FOX13 Salt Lake City. "I knew if I lost those, I could still live, so I really just tied the ends of my jackets together. I tucked my arms inside my jacket and tucked my head inside my jacket.”

Knowing that if he fell asleep he might never wake up, the teen said he set an alarm on his phone to go off every 30 minutes. He grasped a beaded bracelet his ex-girlfriend had given him to help think about all those who cared for him and pushed himself to survive.

PACIFIC CREST TRAIL HIKER, 50, RESCUED AFTER EBAD STORM HITS, SAYS HE 'WOULDN'T HAVE SURVIVED ANOTHER NIGHT'

“I didn’t want PB&J to be my last meal,” he joked to reporters, according to KSL-TV.

But as the night wore on, the teen imagined his friends were in the cave and had what he believed could be his final conversations with them. He wrote letters to his family in case he didn’t make it out alive.

When the sun rose in the morning, he walked out of the snow cave, leaving behind his wet clothes and the boots too frozen to tie. Eventually, he came across some skiers who had a satellite phone.

Search and rescuers airlifted the teen out of the canyon by helicopter. He was about 6 miles from where he started his hike, authorities said.

SEARCH TEAMS RETURN TO DEADLY IDAHO AVALANCHE SITE AFTER 'OVERDUE SKIER' REPORTED MISSING, POLICE SAY

“I’m very lucky,” Stacy-Alcantara said. “I shouldn’t even be alive right now.”

Now, the high school student is recovering from hypothermia and second-degree frostbite that left bubbling blisters on his feet and toes. He’s not expected to need amputation.

CLICK HERE FOR THE FOX NEWS APP

He is set to graduate from high school this year and plans to study aerospace engineering in college.

The Associated Press contributed to this report.