The night can be particularly dangerous for Deacon in Days Gone, especially because Hordes of Freakers will roam around the game during the night. They tend to hide out in caves or other places during the day, so a lot of people like to sleep during the nights if they don't want to deal with the hordes.
There will be a bigger presence of Cultists during the day though, so there's also some drawbacks to sleeping during the night. However, you can use the sleep feature to change between day and night, since some missions and quests will be easier to do during the day, and the other way around.
It is generally adviser to just sleep during the nights at the beginning of them game when you are still new to it, and gradually spend more time playing during the nights when you get more comfortable. But it's up to the player how they want to deal with this of course.
Before you can sleep, you must find either a bunker or a safe house. These are scattered all around the map, and all of them contain a bed. Now locate the bed in either of these, then click on the square button to initiate sleep. These shelters also provide full protection from all the enemies in the game, and none of them can enter a safe house or bunker at any point.
If you sleep during daytime (after 6AM), you will wake up at 6PM the same day.
If you sleep during nighttime (after 6PM), Deacon will wake up at 7AM the next day.
It is not possible to wake up at any other time, and you will always wake up at the closest one. This means that if you go to bed at 5PM, you will essentially only get one hour of sleep. However, you can just sleep one more time if you are unhappy with the result, so it's not a big deal.
Sleeping in Days Gone does not really benefit the character in any way, so the only purpose is to manipulate the enemies and other environmental factors like light. So don't expect to get more Health by sleeping in this game.
You will have the option to save the game when you sleep, so it's also a great way to force a save state.