Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Epoch seconds to "10 seconds ago", "2 minutes ago", "4 hours ago", etc

Posted on 2007-10-01
Medium Priority
Last Modified: 2010-03-05
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?

Question by:zumpoof
LVL 17

Accepted Solution

mjcoyne earned 2000 total points
ID: 19995760
See the Date::Manip module at http://search.cpan.org/dist/Date-Manip/Manip.pod.  It's strength is doing things exactly like this...
LVL 19

Expert Comment

by:Kim Ryan
ID: 19995770
This should help, but it wont work out if seconds are singular or plural etc
LVL 17

Expert Comment

ID: 19995774
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...
LVL 85

Expert Comment

ID: 19996039
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?

Author Comment

ID: 19996343

I just need it to be an approximation. The list I gave above is about as specific as I'd need.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question