Preheat oven to 375°F and butter a large baking dish. Slice potatoes 1/4" thick and place in water to keep from browning.
Ina large skillet over medium heat, melt butter. Add garlic and cook until fragrant, about 1 minute. Add cream, milk, thyme, nutmeg, salt, and red pepper flakes. Bring to a boil and reduce heat to low. Let simmer 10 minutes. Remove from heat.
Layer a third of potatoes, slightly overlapping, in prepared dish then pour a third of cream mixture over potatoes. Repeat with remaining potatoes and cream to make two more layers. Sprinkle Gruyere over top.
Cover with foil and bake for 45 minutes. Uncover, sprinkle with Parmesan and continue baking until potatoes are tender and top is golden, 15 to 20 minutes. Let sit for 10 minutes before serving.