improve and perfect getTimeString function

improve and perfect getTimeString function