The stock market has been relatively calm in recent weeks, but investors got a reminder on Thursday of just how quickly volatility can return. After opening relatively flat, major market benchmarks plunged in the afternoon as investors started to lose confidence in how far tech stocks can lead the overall market higher. Losses were most pronounced in the Nasdaq Composite, but the Dow Jones Industrial Average (^DJI 0.40%) and S&P 500 (^GSPC 1.02%) weren't able to avoid significant declines.

Today's stock market

Index

Percentage Change (Decline)

Point Change

Dow

(1.31%)

(354)

S&P 500

(1.23%)

(40)

Nasdaq Composite

(2.29%)

(245)

Data source: Yahoo! Finance.

In times of trouble, investors often turn to defensive stocks to protect their portfolios from losses. That strategy worked pretty well today, as well-known consumer staples giants Hershey (HSY -0.53%) and Unilever (UL 0.63%) (UN) gained ground after reporting solid earnings results for the second quarter.

A sweet deal for Hershey shareholders

Hershey shares climbed 6% as investors celebrated how well the candy company did in the second quarter. The results showed just how difficult things have been during the period, but Hershey held up better than some had feared.

Sales were down 3.4% for the quarter on a 7% drop in sales volumes, and net income was down 13% year over year. But after accounting for extraordinary items, adjusted earnings per share were flat compared with year-earlier results.

A broken string of three rectangles of Hershey chocolate, revealing caramel and nuts inside.

Image source: Hershey.

Interestingly, international markets were where Hershey saw the most pressure. North American sales were actually up 1%, and the company gained market share in areas like candy, mints, and gum. But COVID-19 played a key role in Hershey's strategic-focus markets of Mexico, Brazil, India, and China, where net sales plunged 43% year over year.

Investors were pleased to hear that management expects sales growth to accelerate in the second half of 2020, with more favorable pricing and effective cost management adding to profits. A slower recovery is likely internationally, but overall, Hershey is optimistic about its ability to weather the crisis and emerge stronger than ever.

A clean bill of health for Unilever

Elsewhere, Unilever shares climbed almost 7%. The maker of everything from soap and household products to food items posted mixed results, but investors were pleased with the general picture.

Sales at Unilever were down slightly during the first half of 2020, falling 0.1% on an adjusted basis as modest price gains offset minor volume declines. Underlying earnings per share climbed more than 6% year over year, even with negative currency impacts weighing on the bottom line.

From a segment perspective, the home-care division performed the best in the first half, with 3.2% sales growth stemming from strong increases in volume. The food and refreshment category took the biggest hit, as segment sales eased lower by 1.7% in the first half. Revenue from beauty and personal-care products was also modestly down. As the company explained it, more people staying at home contributed to sales of tea, ice cream, and other food items. But personal-care needs were less extensive, and Unilever's food-service and outside-the-home ice cream retail stores saw huge declines.

As with Hershey, Unilever got strong results in North America, but China and India weighed on performance internationally. Europe also took a large COVID-19 hit.

Investors have largely ignored defensive stocks in the shadow of tech's run-up. If the market corrects now and tech stocks lead the way lower, though, then areas like consumer staples could shine.