Perl DateTime nanoseconds always 0

Viewed 87

How i can get nanosecond from DateTime in Perl?

I try

say DateTime->from_epoch(epoch => time)->nanosecond; # 0
say DateTime->from_epoch(epoch => time)->strftime('%9N'); # 0
2 Answers

time returns the number of (whole) seconds since the start of the unix epoch. Time::HiRes provides a version of time with better resolution.

Related