updated code dealing with time in databases