Properly format timestamp for sprintf