the time ago in block 3 is correct but another block is wrong time.

Posted in: Newspaper
Post count: 28

i use this link <?php echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ) . ‘ ago’; ?>

but another module is wrong time with bock3 in module 1

could you please help me!

Post count: 22421

Hello,

Ok, but did you implement the code on all modules? They each have their own file and all of theme have to be modified: https://www.screencast.com/t/sAILJL8stu

Thank you!

Post count: 28

yes i copy to all modules and and it show time ago in all block but all show time is wrong like ‘i just public but it show 2hour ago’ show what wrong with this.

please help.

Post count: 20685

Hi,

Try the code like this
https://www.screencast.com/t/rnAo76A8dDkG
Then it should work properly
https://www.screencast.com/t/y0FpQntGHN

<?php echo human_time_diff( get_the_time('U', $this->post->ID), current_time('timestamp') ) . ' ago'; ?>

It may further require some styling to align the time, that can be done with some CSS.

Thanks

Post count: 28

Can you tell me where the human_time_diff function?

Post count: 28

i want to change time ago option.
thank you..

Post count: 20685

Hi,

I don’t understand exactly what you want to modify. If it is the time format you can change the time parameters in the code
https://codex.wordpress.org/Function_Reference/get_the_time
https://codex.wordpress.org/Formatting_Date_and_Time
The current code works as mentioned here
https://codex.wordpress.org/Function_Reference/human_time_diff

Thanks

Post count: 11

how can it be styled ?

Post count: 20685

Hi,


@wizimatic
You could wrap the code in a div with a custom class, like this
https://www.screencast.com/t/BR1BkgCP1TC
Then refer to that class and style the date as you want
https://www.screencast.com/t/AeY3jqDq9fo8

https://forum.tagdiv.com/create-custom-code-using-the-browsers-inspector/

Post count: 11

Can i use your code <?php echo human_time_diff( get_the_time(‘U’, $this->post->ID), current_time(‘timestamp’) ) . ‘ ago’; ?> for post pages (single.php) sir?

I put

<?php echo human_time_diff( get_the_time(‘U’),
current_time(‘timestamp’) ) . ‘ ago’; ?>

on my mobile front page but i need the code to put on the single.php that will show timeago for individual posts.

just wondering about the difference between the two codes which is $this->post->ID

Also, There is a dash (-) inbetween the authors name and category name on my homepage(using the newspaper mobile theme), i dont know how to hide it and make the meta info closer to each other.

Also, how do i include the time ago on the featured posts.

my url is https://wizimatic.com (pls access from mobile to see)

The styling using “myclass” worked perfectly.

Post count: 20685

The modules displayed on the mobile front page are here
https://www.screencast.com/t/M9XfBgdPcs
Edit them with the time format code if you want to. The single file for the mobile theme is this one, edit it like this
https://www.screencast.com/t/TfONnKLv0

Post count: 11

Done. How can I style the time ago on single.php posts separately. It doesn’t align, jumps up a little.

How can I include the time ago on featured posts on mobile theme

Post count: 11

how can i limit the time ago to a month and it should the normal date if its more than a month

Post count: 11

i used this code <?php
$time = human_time_diff(get_the_time(‘U’), current_time(‘timestamp’));
$pos = strpos($time, ‘months’);
if ($pos>0) {
echo $td_mod_single->get_date(false);;
}
else{echo $time . ‘ ago’;}
?>

but the styling class didnt work the moment the posts is over a month. The date didnt align with other metas

Post count: 20685

Maybe move the other meta instead of the new time format
https://www.screencast.com/t/Lu6RZgNDx

header .td-module-meta-info .td-post-author-name {
top:0;
}

Or do it the same with a div and class. For the mobile theme, CSS code has to be entered here
https://www.screencast.com/t/CsHYYBlQFh7

That code works for me, posts within a month
https://www.screencast.com/t/Ou41YeLbgd
Older posts – https://www.screencast.com/t/5p0PvZjvjq
How did you setup the styling ,what is happening exactly? Provide a link to the website where I can see this if possible.

Post count: 11

You can check on mobile.. Here is a recent post, the meta information aligns properly, http://wizimatic.com/china-releases-3-year-plan-for-air-pollution-control/
Here is a long time post; https://wizimatic.com/infantino-wants-video-refs-for-2018-world-cup/
the post meta (date) doesnt align. I use the same div class for it. Here is the code that i am using, right in single.php

<div class=”classing”><?php
$time = human_time_diff(get_the_time(‘U’),

current_time(‘timestamp’));
$pos = strpos($time, ‘months’);
if ($pos>0) {
echo $td_mod_single->get_date(false);;
}
else{echo $time . ‘ ago’;}
?></div>

Post count: 11

please check on mobile as i didnt edit the desktop pages

Post count: 20685

This is not valid – https://www.screencast.com/t/5nM9WmAP
Be sure to use px and not such a high value, with -15px it will be too high
https://www.screencast.com/t/LfaC894drtm

In the other example a value like this would be best
https://www.screencast.com/t/HPaQec5A

You could add divs individually, for each case, like this
https://www.screencast.com/t/YEALpxfDW
Then style them differently if needed.

Post count: 11

Okay thank you so much. That really helped. However the last problem I’m facing is, on my single posts (mobile theme) related posts are inheriting the date of the posts. That is, if the post has a time of 1hr ago, all related posts below the posts also have 1hr.
You can check using this post link below;
https://wizimatic.com/fresh-music-b-red-run-come-ft-cdq/

Post count: 20685

I tested your code, that is not happening for me
https://www.screencast.com/t/vckRb9ml
https://www.screencast.com/t/UYDsjbhq

Also an older post – https://www.screencast.com/t/TWev3wgE
https://www.screencast.com/t/Ww3QVJZFRY

I used the same code with condition you provided, in the mobile theme single file
https://www.screencast.com/t/xPyhiQ4nSs
Maybe double check your modification.

Post count: 11

This is the code i am using on my single.php page (post page on mobile theme)

<?php
$time = human_time_diff(get_the_time(‘U’),

current_time(‘timestamp’));
$pos = strpos($time, ‘months’);
if ($pos>0) {echo ‘<div class=”classing”>’ . $td_mod_single->get_date ( show_stars_on_review, false) . ‘</div>’;}
else {echo ‘<div class=”classing1″>’. $time . ‘ ago’. ‘</div>’;}
?>

and its bringing same time for posts and related posts

Post count: 20685

Remove the code and return to default, see what happens. If there is no problem enter it again

<?php
$time = human_time_diff(get_the_time('U'), current_time('timestamp'));
$pos = strpos($time, 'months');
if ($pos>0) {
echo $td_mod_single->get_date(false);;
}
else{echo $time . ' ago';}
?>

This is the same code I used and it works as shown above. Test and check all the other modifications made until now. test only with the mobile theme modification maybe, remove all others temporarily.

Post count: 11

I used the default code and it still shows the time ago on related post. I guess it’s inheriting it from the front page time ago code.
How do I set the time ago for related articles

Post count: 20685

Maybe you modified the mobile theme modules
https://www.screencast.com/t/Lz1RKpyiDf
The related articles module is module 1, check the modifications made there.

Viewing 24 posts - 1 through 24 (of 24 total)
You must be logged in to reply to this topic.