During the day, and most evenings it is pretty much up to you. But it also depends which cruise line you go with.
Cunard is considered to be the most traditional. We went with my in laws last year, on our first cruise, although my MiL had been before, on Cunard’s Queen Anne, and were informed in advance of the themed formal nights - black and white, 1920’s and masquerade.
There were still loads of people, seasoned cruisers, I guess who didn’t follow that theme, and they weren’t prevented from entering the dining rooms.
The Commodore Club, which was the ship’s classier bar, had a no shorts, no ripped jeans after 6pm, but even on the themed night, a decent pair of trousers and a smart top and you wouldn’t look out of place, or a dress that you might wear to a nicer restaurant for a special birthday or anniversary dinner, for example. And swimwear is considered a universal no-no in any of the dining areas, but a simple dress or other cover over, and a t-shirt for the men with shorts, and you are set for lunch.
Other cruise lines have their own posted dress codes for evening events but I think it’s very rare that they are implemented, except for what I said above. And they all have a dining area that is casual all the time - the buffet restaurants. Queen Anne’s was EXCELLENT last year. And although it was called a buffet, you were served by staff, and there were sneeze guards everywhere. The options were AMAZING, whether you were there for breakfast, lunch, dinner or a snack before bed.
watch some YouTube reviews of a cruise line or specific ship you like the look of, and dive into the rabbit hole of cruising!!!
If you love it, you’ll love it forever. I’m sold now. Next one in 13 days.
oh, and waking up somewhere new without having to repack your stuff is just the BEST! THING! EVER!!!