You need to use 'Do not disturb' but only AFTER you've configured the options within that function.
This is based upon my Samsung Galaxy phone but any Android phone should be much the same:
Pull down from the top of the screen.
LONG-press on 'Do not disturb'.
Under 'Exceptions', tap on 'Calls, messages and conversations'.
Tap on 'Calls' and choose 'All', 'Contacts only' or Favourite contacts only', as desired.
That should be all that you need to do. However, while you're in the 'Do not disturb' settings, you might want to use the option to automatically turn on that function between the same hours every night, rather than having to enable it each time that you go to bed.