The best time to write is when your life is in the toilet. Writing offers an escape from your problems, so if you force yourself to write when you're in the doldrums, it will have the perverse effect of cheering you up. At the very least, it allows you to inflict your pain on your characters, which has the dual effect of giving them more depth while relieving your own tension.