Pregnant

Me & my ex boyfriend is no longer together and I just found out I'm pregnant today. When should I tell him? How would I go about telling him? I'm really nervous