My name is Pete and I am a health enthusiast. One of my recent experiments was to see whether humans can live off of fruits and vegetables alone, without cupped hydration (water and etc…)
It has been four months now.
I am looking for a sort of stopwatch/reverse countdown plugin. Something that will read years, months, weeks, days, minutes, seconds. A time since sort of plugin.
Thanks,
-Pete
The example on that page is the following:
<?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>
It shows the timestamp in relative to “days”. How can I tweak it to automatically switch between the following pseudocode:
if time < 1 hour
echo minutes
elseif time < 1 day
echo hours
elseif time < 7 days
echo days
elseif time < 30 days
echo weeks
elseif time < 365 days
echo months
elseif time >- 365 days
echo years
I’m aware that there are plugins, but I’m trying to keep bloat minimal by writing a simple function that I can throw into functions.php. Could someone please give me a example of how to tweak that?
]]>I’m trying to make the time stamps on my comments and entries more user friendly – the desired effect is virtually the same as this forum, where (for example) in each comment on a blog entry the time will be written “1 day 3hrs ago”…
I’ve searched around and have come across a few old techniques here, here and here.
Can anyone give some advice on how to get the desired effect?? Either plugin or hack.
Many thanks – Leon.
]]>So first, I was using the php code as provided by the default theme:
<$ php $entry_datetime = abs(strtotime($post->post_date)
- (60*120)); echo time_since($entry_datetime); echo '
ago'; ?>
And that worked fine except for on entries that are posted on the day of. I made a test entry today and it said something like ‘This entry was posted -1 year, 256 days ago,’ which is a roundabout way of saying today, I guess.
So, I went to the plugin site and copy and pasted the code from there:
`
<?php if (function_exists(‘time_since’)) {
echo time_since(abs(strtotime($post->post_date_gmt . “ GMT”)), time()) . “ ago”;
} else {
the_time(‘F jS, Y’);
} ?>’
And that gives me this error:
Parse error: parse error, unexpected T_STRING in /index.php on line 12
which I know has something to do with not putting in backslashes where there’s a single quote or something of that sort, but I can’t see the error (probably due to inexperience).
I need help on one of two things: make the first code work better. I’d like a post that I post today to say “this was posted x hours, x minutes ago.” It works now, just not the way I’d like it to.
Or. Find the error in the second code so that I can see if that one works any better.
Please and thank you! I’d really appreciate any help on this.
]]>Parse error: syntax error, unexpected ‘}’ in /home/erin/public_html/wp-content/themes/default/index.php on line 39
Is there something I’m missing? I copied the code exactly.
]]>At the moment the templates work better with firefox and opera. Some little bug with IE6
]]>