Relative timestamps
Categories
Component ID
1920568
Component name
Relative timestamps
Component type
module
Maintenance status
Development status
Component security advisory coverage
covered
Downloads
848
Component created
Component changed
Component body
This module aims to provide an extra display formatter for Date fields from the Date module. As the supplied timestamp gets older, less accurate information will be shown. Future dates and end dates are also supported.
Usage example
This module is intended for developers who need a timestamp as currently being featured on Facebook. Likewise the module could be used in conjuction with activity stream modules such as Message, Heartbeat and Activity.
Supported time strings
- # second(s) ago / in # second(s)
- # minute(s) ago / in # minute(s)
- # hour(s) ago / in # hour(s)
- yesterday / tomorrow
- # days ago / in # days
- # month(s) ago / in # month(s)
- # year(s) ago / in # year(s)
If an end date has been provided, the module will return the correct time string depending on the situation:
- from ### ago until ### ago
- from ### ago until ### from now
- from in ### until ### from now
- + some slight alterations for the cases yesterday / tomorrow
Output example
Date field is set at 2013-02-20 21:00:00 UTC
- if viewed at 2013-02-20 21:05:00 UTC: 5 minutes ago
- if viewed at 2013-02-20 21:50:00 UTC: 1 hour ago
- if viewed at 2013-02-20 23:45:00 UTC: 4 hours ago
- if viewed at 2013-02-21 21:15:00 UTC: yesterday
- if viewed at 2013-02-21 07:00:00 UTC: yesterday
- ...
