How can I add the date and time to my blogger posts?

Batersch

Well-known member
Joined
May 14, 2019
Messages
262
Hello, I am currently using the GAMEIFY template and would like to integrate a script that modifies the date, displays the duration since the post was published, and indicates the estimated reading time. I would greatly appreciate any assistance or guidance on how to accomplish this.


3.png
 
If I understand correctly, you're suggesting adding read time and time since the post was published using plugins and simple calculations.

For read time, you can indeed use a plugin that counts the total words and calculates the estimated reading time based on that.

As for displaying the time elapsed since the article was posted, you can use a system like this: Current date - date the article was posted = [x] days ago If the elapsed time is more than 365 days, display it as 1 year ago (or the appropriate number of years).

To achieve this, you'll need to add a simple counter function in your template or use an available plugin that offers these features.
 
If I understand correctly, you're suggesting adding read time and time since the post was published using plugins and simple calculations.

For read time, you can indeed use a plugin that counts the total words and calculates the estimated reading time based on that.

As for displaying the time elapsed since the article was posted, you can use a system like this: Current date - date the article was posted = [x] days ago If the elapsed time is more than 365 days, display it as 1 year ago (or the appropriate number of years).

To achieve this, you'll need to add a simple counter function in your template or use an available plugin that offers these features.
I need assistance because I'm unsure. Which script should I add, and where in the template?
 
I need assistance because I'm unsure. Which script should I add, and where in the template?
On the template, you could modify the 'show date' section by editing the single.php file or any related PHP file. Please note that I am not using the same theme as you are."

Essentially, the speaker is suggesting a way to customize a template by making changes to a specific PHP file that controls the display of the date. They clarify that their solution is tailored to their specific theme, which may differ from the one used by the listener.
 
On the template, you could modify the 'show date' section by editing the single.php file or any related PHP file. Please note that I am not using the same theme as you are."

Essentially, the speaker is suggesting a way to customize a template by making changes to a specific PHP file that controls the display of the date. They clarify that their solution is tailored to their specific theme, which may differ from the one used by the listener.
The template doesn't offer that particular option. Kindly assist me or guide me to a resource with detailed instructions, if possible.
 
The template doesn't offer that particular option. Kindly assist me or guide me to a resource with detailed instructions, if possible.

You can locate code for counting dates/days on platforms like GitHub or Stack Overflow.

However, if you're seeking step-by-step guidance from start to finish, I apologize, but I am not able to offer coding services for free. I encourage you to collaborate with your IT team to achieve your desired outcome bro. Or seek some help via fiver..
 
Hello, I am currently using the GAMEIFY template and would like to integrate a script that modifies the date, displays the duration since the post was published, and indicates the estimated reading time. I would greatly appreciate any assistance or guidance on how to accomplish this.


View attachment 28281


Bruh, the function you need in WordPress for this task is human_time_diff(). You can insert the following code at the end of your theme's functions.php file:


For posts (posted on):-

function my_timeago_post()
{
return sprintf( esc_html__( '%s ago', 'textdomain' ), human_time_diff(get_the_time ( 'U' ), current_time( 'timestamp' ) ) );
}
add_filter( 'the_time', 'my_timeago_post' );


For comments (comment date) :-


function my_timeago_comments()
{
return sprintf( esc_html__( '%s ago', 'textdomain' ), human_time_diff(get_comment_time ( 'U' ), current_time( 'timestamp' ) ) );
}
add_filter( 'get_comment_date', 'my_timeago_comments' );


This is an internal WordPress function, so consult the wp.org Codex (documentation) for more information on its usage. You can learn how to format it in specific ways based on your desired conditions, such as displaying time in weeks or days if a post is older than a certain period, among other options.
 
Sorry, I only just realized that you're using Blogger. Instead, you can find the 'human_time_diff' function in the source code of WordPress on GitHub, or you can download WordPress and search for the function within its files. Once you find the code, you can use it.. Good luck!
 
Back
Top Bottom