开发者

How to translate timestamp in miliseconds to time?

开发者 https://www.devze.com 2023-03-17 15:17 出处:网络
How do I translate a timestamp in miliseconds to a time format like \"13:52:11.12开发者_如何学Python\"?use DateTime;

How do I translate a timestamp in miliseconds to a time format like "13:52:11.12开发者_如何学Python"?


use DateTime;
my $t = time() * 1000 + 400;

print DateTime->from_epoch(epoch => $t/1000)->format_cldr('H:m:s.S');
# 13:22:47.4


divide by 1000 to get seconds.
Divide by 86400 to get days
Divide remainder of above division by 3600 to get hours
Divide remainder by 60 to get minutes, remainder is seconds
0

精彩评论

暂无评论...
验证码 换一张
取 消