Updated code to fix date time in database