Reputation: 19
How to i get the difference between a file created time and the current time in hours
Upvotes: 2
Views: 187
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
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