The object of getting the date / time in a fixed length string like this is to be able to perform comparisons on log file lines. Unless you have access to the log script and can change the time format to timestamp, time / localtime / sprintf is about as efficient as you can get.