Added null protection and changed date time object to be in the correct format