You know that feeling when you have been looking at a screen and you have a strong hunger to pick it up again? Do some experimenting to find the amount of time it takes you to get over this feeling, then unplug that much time before bed. This could be anywhere from 30min-90min.
I think that depends on your routine. I, personally, take a shower before I go to bed, so once I am out of the shower I usually have my phone plugged in and I dont use it, unless it's for music or emergencies of course.