I was kind of hoping that I wouldn't have to do " setfill ('0') << setw (2)<<" so many times. Do you know of any way to set them all as that by default? Then I would only have to change the millisecond to 3 at the end. If not don't worry about it, it's messy but it'll do the job.
Is there anyway to save this as a string or something in exactly this format "2011-08-04 04:53:03.904" so that I can print out that string later instead of printing it out immediately?
Thanks, it also turns out that when you do it once, it remembers that for the rest of them. Therefore it is only actually necessary to <<setfill('0') once at the start. However setw seems to have to be done before every number.