This plugin displays the number of years, months, days, hours and minutes since a post or a page was published or modified, or a comment was published, in the same format as Facebook, Twitter etc. Examples are “Just now” (less than a minute ago), “47 minutes ago” (less than an hour ago), “3 hours ago” (less than a day ago), “Yesterday”, “3 days ago”, “One week ago”, “3 months ago”, “3 months, 4 days ago”, “2 years, 13 days ago” and so on. It’s also possible to configure wp-days-ago to fall back to displaying the actual date and time when a certain number of seconds after publishing time has been reached.
Cache plugins, like W3 Total Cache and WP Super Cache, are supported through the use of AJAX. This means that the plugin will show correct information even if the page is cached. Please see the installation instructions, and the stopUsingAjaxAfter parameter in particular, for details.
- Bengali (thanks to Mahmud, C.E.O, S. M. Foundation)
- Dutch (thanks to Marjolein Boer, Pixelein)
- French (thanks to Alondi Commanda, Alondi Consulting)
- German (thanks to WordPress.org user ezkay)
- Indonesian (thanks to FJ Bakry, Camisto)
- Kurdish (Central Kurdish)
- Malaysian (thanks to FJ Bakry, Camisto)
- Norwegian (bokmål)
- Norwegian (nynorsk)
- Persian (Farsi) (thanks to WordPress.org user famarini)
- Russian (thanks to Yuri from www.coinside.ru)
- Spanish (thanks to Andrew Kurtis, WebHostingHub)
- Ukranian (thanks to Alexander Avramenko)
- Download the plugin.
- Unzip the contents of the downloaded file to the /wp-content/plugins/ directory of your WordPress installation.
- Log in to your WordPress dashboard and activate the wp_days_ago plugin that should now be visible in the list.
- You can now insert <? wp_days_ago_v3(); ?> anywhere in The Loop for either posts or comments in your WordPress theme.
<?php wp_days_ago_v3 ($stopUsingAjaxAfter, $showDateAfter, $showDateFormat, $showYesterday, $context); ?>
(int) (optional) The number of seconds since a post or page was published before the plugin should stop using AJAX to display information. The default value is 0, which means the feature is turned off and AJAX is never used. If you have a cached site and the cache update interval is a day or less, 86400 (one day) is a good value for the plugin. The reason for this is that one day after a post or page was published, the plugin will start to show information in daily intervals (“yesterday”, “2 days ago”, “3 days ago”, etc). If the post or page was published less than a day ago, the plugin will update in smaller intervals (“10 minutes ago”, “3 hours ago”, “4 hours ago”, etc) and AJAX is needed to ensure that this is displayed correctly on a cached site. The minimum value should be the cache update interval.
(int) (optional) The number of seconds since a post or page was published before the plugin falls back to showing the actual date and time the post or page was published, instead of in its usual “X days ago” format. The default is -1 seconds, i.e. the feature is turned off by default.
(string) (optional) The format the plugin should use to display the date and time a post or page was published if the number of seconds configured in the showDateAfter parameter has been reached. The default behaviour is to use the date and time formats configured in WordPress, but if this parameter is set, the date and time format it defines will be used instead of the format you have configured in WordPress. See Formatting Date and Time for other time and date formats if you want to override the configured formats.
(boolean) (optional) Option to show the text “yesterday” if there is less than 24 hours since the post or page was published. Otherwise, the number of hours since the post or page was published will be showed until more than 24 hours have passed. Then, the number of days, etc, will be shown. The default value is true.
(int) (optional) The plugin needs to know in what context it’s called. Available values are 1 (post/page published date), 2 (post/page last modified date), and 3 (comment published date). So if you want to show use the plugin to display a post’s modified date, you use 2 as context when calling the plugin in your post/page loop. For comments published date, use 3 as context in your comments loop. The default value is 1.
Information for translators
There’s a POT file in the languages folder if you want to translate the plugin into another language. If you do that, I’d really appreciate it if you could provide me with the PO/POT and MO file so it can be included in future versions of the plugin. You will of course be credited for your work.
In the POT file, there’s a string called “prepender”. This is for languages that need to prepend a word before the number in the string. An example is Norwegian, which will prepend the word “for” before the number: “For 2 dager siden”. “For” is the prepender. Some languages doesn’t use the prepender, English being a natural example. The Norwegian example is “2 days ago” in English. If your language doesn’t need to use a prepender, simply translate the string “prepender” to “[none]” (without the quotes).
This same is the case for the word “ago”. If your language does not use this word, German is one example, simply translate the sting “ago” to “[none]” (without the quotes).
…so of course I love it!
your plugin is usefull
and i translate to persian .
my po $ mo file address is :
I have used this plugin on my website amazinghere. and it works nicely.
Contributors & Developers
“wp-days-ago” is open source software. The following people have contributed to this plugin.Contributors
- Added Malaysian and Indonesian translations (thanks to FJ Bakry, Camisto).
- Change: Replaced empty call to gmmktime() with empty call to time(). This removes the warnings reported here.
- New feature: The plugin can now also be used to show posts/pages modified dates, and comments published dates.
- Added Ukranian translation (thanks to Alexander Avramenko).
- Updated German translation.
- Added support for not displaying the “ago” appender for translations that do not use it.
- Added Kurdish (Central Kurdish) translation.
- Added German translation (thanks to WordPress.org user ezkay).
- Bugfix: Fixed an unfortunate bug where the number of days would be wrong in some cases if “yesterday” was configured not to be shown.
- Bugfix: Remove hard coded “cet” string that was showed when waiting for AJAX call to finish.
- New feature: Option to show number of hours instead of “yesterday” before 24 has passed. “Yesterday” don’t always make sense if you’re having an international audience. The default value is to show “yesterday”, so there is no need to change anything unless you want to use the new option. See the installation instructions for details.
- Added Persian (Farsi) translation (thanks to WordPress.org user famarini).
- Change: Updated Dutch translation.
- Bugfix: Added missing language files.
- Added Bengali translation (thanks to Mahmud, C.E.O, S. M. Foundation).
- Added French translation (thanks to Alondi Commanda, Alondi Consulting).
- Added Dutch translation (thanks to Marjolein Boer, Pixelein).
- Added Russian translation (thanks to Yuri from www.coinside.ru).
- Added Spanish (thanks to Andrew Kurtis, WebHostingHub), Turkish, Swedish and Norwegian (nynorsk) translations.
- Bugfix: Fixed some edge case bugs.
- Change: Version 3.0.0 is a complete rewrite of the plugin. Functions from version 2.x are still available to ensure backwards compatibility and will continue to work as they used to, but bugs will not be fixed. It’s highly recommended that you start to use the _v3 methods described in the installation instructions if you upgade from version 2 or an even earlier version.
- Change: Now supports translations, see included POT file if you want to translate the plugin into your language.
- Change: When calculating days, the plugin will now ignore the publishing time and only use the actual date.
- Change: When calculating years, the plugin will now take into account leap years.
Both changes should lead to a more accurate output from the plugin.
- New feature: Support for falling back to showing the date and time a post or page is published instead of “X days ago” and similar a configured number of seconds after the post or page is published. The feature is turned off by default, so if you are upgrading from a previous version of wp-days-ago, there is no need for you to change anything unless you want to use this new feature.
- Bugfix: Fixed a major bug that happened when using the wp_days_ago method. Thanks to user heinnge for reporting this.
- New feature: Added a threshold parameter to control when AJAX should be used and when the plugin should automatically fall back to the old way of displaying information. After a day, the plugin doesn’t display any detailed information anyway so there is no need to strain the server with a lot of AJAX calls. The information displayed by wp-days-ago will of course be updated when your cache plugin invalidates the content and rebuilds it. The value of the wp_days_ago_ajax method threshold paramterer should match the configured invalidation threshold of your cache plugin.
- Change: Optimized date calculation and database access code.
- New feature: Cached sites are now supported through the use of the wp_days_ago_ajax function. See above for details.
- Change: Minimum required version of WordPress is now 2.1.
- New feature: Added text “Some time in the future” for scheduled posts (visible in preview mode only).
- Change: Removed some debug code that had made its way into the release.
- New feature: The plugin now by default displays minutes and hours since a post or page was created.
- Change: The $offset parameter from the 1.x version is now replaced with a $mode parameter that enables you to prevent the plugin from displaying the minutes and hours since a post or page was published and instead fall back to “Today” for everything published lest than 24 hours ago.
- Changed some of the default texts so that they start with a capital letter.
- Backwards compatible all the way back to WordPress 1.5.
- The plugin now uses the internal WordPress timezone settings.
- Added optional parameters that allows configuration of appended text, prepended text and the texts displayed by the plugin.
- Initial version.