After a bit of work, I finally got DateTime to recognize the time value from Time::HiRes and format it correctly for my test database.
#!/usr/bin/env perl use strict; use warnings; use DateTime; use aliased 'DateTime::Format::Strptime'; # 2008-09-18T16:00:20 my $format = Strptime->new( pattern => "%FT%H:%M:%S.%5N" ); # this is the format that Time::HiRes will return the time() my $datetime = DateTime->from_epoch( epoch => 1221753628.79859 ); $datetime->set_formatter($format); print $datetime; __END__ 2008-09-18T16:00:28.79858
You can actually get finer granularity from Time::HiRes, but my god, this is for the start and end of each test program. You won't need finer granularity than this.
And at that number of decimal places, you are already totally constrained by the time quanta that the OS supplies.