zumpoof
asked on
Epoch seconds to "10 seconds ago", "2 minutes ago", "4 hours ago", etc
I'd like to be able to convert epoch seconds values into strings like:
"10 seconds ago"
"2 minutes ago"
"1 hour ago"
"4 days ago"
"3 weeks ago"
"2 months ago"
Can someone post the code to do this, or perhaps point me to a library that does this?
Thanks,
Zumpoof
"10 seconds ago"
"2 minutes ago"
"1 hour ago"
"4 days ago"
"3 weeks ago"
"2 months ago"
Can someone post the code to do this, or perhaps point me to a library that does this?
Thanks,
Zumpoof
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In the Date::Manip documentation, see especially the Delta_Format section, where you can express, say, 120 seconds in terms of minutes, and so on...
Will you ever want strings like "1 hour and 10 seconds ago"?
Do you want to be able to define when we want to switch from using one unit to using another?
Do you want to be able to define when we want to switch from using one unit to using another?
ASKER
Ozo,
I just need it to be an approximation. The list I gave above is about as specific as I'd need.
I just need it to be an approximation. The list I gave above is about as specific as I'd need.
http://search.cpan.org/~msergeant/Time-Piece-1.11/Seconds.pm