ocpsoft/prettytime

Just get "Days Ago"

Closed this issue · 3 comments

Is there a way to just get back "Days Ago"? For example if it's 7 days instead of it giving me back "1 week" ago it'll give me back 7 days ago. Instead of 1 month ago it'll give me back 30 days ago, etc.

@HermanKayy Yes, you need to manually pass only the Day time unit to the PrettyTime configuration, after removing all others:

PrettyTime p = new PrettyTime();
p.clearUnits();
Day day = new Day();
p.registerUnit(day,  new ResourcesTimeFormat(day));
p.format(new Date());

Working on an easier API for this in Version 5.

New API here: 0889435