Fix the problem of substr out of range with empty timestamp.