The S&P 500 and Nasdaq closed higher for a second day as softer U.S. inflation data and a temporary U.S.-China tariff truce boosted investor confidence.