Fix format time function