Preheat the oven to 375°F (190°C) and grease a 9x13 inch baking dish with butter.
In a medium saucepan, melt the butter over medium heat. Add the diced onion and cook until translucent, approximately 5 minutes.
Whisk in the flour and garlic, cooking for 2 minutes to create a blonde roux.
Slowly whisk in the milk and heavy cream, stirring constantly to prevent lumps. Simmer until the sauce thickens enough to coat the back of a spoon.
Stir in the salt, black pepper, and dried thyme, then remove the sauce from heat.
Arrange half of the potato slices in an even, overlapping layer in the prepared baking dish.
Pour half of the cream sauce over the first layer of potatoes.
Layer the remaining potatoes on top and pour the remaining sauce evenly over the surface.
Cover the dish tightly with aluminum foil and bake for 45 minutes.
Remove the foil and continue baking for 25 minutes until the potatoes are fork-tender and the top is bubbly and golden brown.
Let the dish rest for 10 minutes before serving to allow the sauce to thicken.