It took me a while to figure out how to make the relative date be something other than post-date to current-date. It is not unusual that people want the relative date to be relative to a certain fixed historical point–for example, the age of a child or the length of a trip. I think people would appreciate some examples in the documentation of what this should look like. For example, the following would give the age of a child born on 1/1/2010:
get_relative_date( strtotime("1/1/2010") , get_the_time( 'U' ) , ", ", "2" )
Of course, integrating it into a theme will be different for each theme, but some guidance could be provided for that as well.
This plugin will report dates like “4 weeks 3 weeks” when it means “4 weeks 3 days,” and similarly for days/hours. There is a simple fix which I’ve included below in unified patch format. I hope this can be included upstream so it won’t have to be reapplied on upgrade.
--- wp-relative-date.php 2016-09-21 12:09:46.000000000 -0400
+++ wp-relative-date.php.fixed 2017-04-09 14:49:55.062825466 -0400
@@ -358,14 +358,14 @@
// Weeks and days
$relative_date .= ( $relative_date?$divider:'' ) . $weeks . ' ' . ( $weeks>1?$week_plural:$week_singular );
- if ( ( $days > 0 ) && ( $depth == 2 ) ) { $relative_date .= ( $relative_date?$divider:'' ) . $days . ' '.( $days>1?$week_plural:$week_singular );}
+ if ( ( $days > 0 ) && ( $depth == 2 ) ) { $relative_date .= ( $relative_date?$divider:'' ) . $days . ' '.( $days>1?$day_plural:$day_singular );}
} elseif ( $days > 0 ) {
// days and hours
$relative_date .= ( $relative_date?$divider:'' ) . $days . ' ' . ( $days>1?$day_plural:$day_singular );
- if ( ( $hours > 0 ) && ( $depth == 2 ) ) { $relative_date .= ( $relative_date?$divider:'' ) . $hours . ' ' . ( $hours>1?$day_plural:$day_singular ); }
+ if ( ( $hours > 0 ) && ( $depth == 2 ) ) { $relative_date .= ( $relative_date?$divider:'' ) . $hours . ' ' . ( $hours>1?$hour_plural:$hour_singular ); }
} elseif ( $hours > 0 ) {
]]>
Hi ??
As with all my plugins, I present this to you for free. There no ads, nags or premium options. Support is free too.
As for everyone, my time is limited. It’s just me and NOT a team of people. If you post here I should get an email straight away and I’m quite good as responding quickly. But, yeah, I may not always due to numerous reasons, including holiday (aka vacation). And, no, I won’t tell you when I’m going to be away. At the end of the day, I’ll do my best. I can’t do anything more, surely?
If you’re interested you can see current planned enhancements and reported bugs (as well as roadmaps for planned work) here…
https://artiss.co.uk/bugtracker/index.php?project=10
Have fun, enjoy the plugin and, if you don’t, let me know – support queries and reviews are always welcome!
]]>Installed, activated, and nothing! Same old original date still showing. Using WordPress Theme 2011.
]]>Hi dartiss,
I would like to Custom the Artiss Relative Date Plugin, And i want like this;
over a days old, just show date (“F j, Y”)
days and hours
hours and minutes
minutes only
seconds only
if you helped me to do with this i’ve be very happy to use this plugin long as possible… and you can drop me a full custom code for relative-date.php on pastebin or whatever you can ??
Thanks
Sulaiman
]]>Thanks for your time and the elegant code on the plugin.
Pothi
]]>