jeny
jeny

Reputation: 19

How to i get the difference of time in hours for a file created time and the current time using perl

How to i get the difference between a file created time and the current time in hours

Upvotes: 2

Views: 187

Answers (2)

salva
salva

Reputation: 10234

For calculations involving time or dates you can always rely on DateTime!

For your specific cuestion, you can use the constructor from_epoch to convert from Unix timestamp to DateTime.

Upvotes: 1

thomas
thomas

Reputation: 2308

stat($file)->mtime gives you the last modification time in seconds. Subtract that from time and divide it by 3600 ... that should do the trick.

Upvotes: 4

Related Questions