Currently, I have my posts post exactly 1 day early. This works fine on my website though the back end is sloppy. What I am having problems doing is adjusting the post time on my feed. By far the majority of my listeners are in the US and I want the feed to simply show the correct post time for only central time zone.
I am trying to adjust the feed date and time. This is how I am going about it:
function get_early_post_time_for_feed ($id) {
$early_time = strtotime(get_the_time( 'D, d M Y H:i:s O' , $post = $id ));
$early_time = strtotime('-1 day', $early_time);
$early_time = date('D, d M Y H:i:s O', $early_time);
return ($early_time);
}
And here is the problem:
echo get_early_post_time_for_feed (2121);
Outputs:
Mon, 27 Apr 2020 09:00:00 +0000
But…
echo get_the_time( 'D, d M Y H:i:s O', $post = 2121 );
Outputs:
Tue, 28 Apr 2020 04:00:00 -0500
Why is the time off? And how can I fix it?
I understand that the time is not technically “off”. But how do I make the function output look the same as the wordpress function output?
And will this work for my feed?
Thank you.
]]>Plugin is working fine, but I have a question regarding the human_time_diff of the imported posts.
I am using the following code to display how much time ago the post has been published (for example: 5 mins ago)
<?php echo esc_html( human_time_diff( get_the_time('U'), current_time('timestamp') ) ) . ' ago'; ?>
In the WP Admin under Posts section I can see that the imported post from an RSS Feed source is 5 minutes ago. But on the front page it displays it adds 1 hour so the result of the human_time_diff function becomes 1 hour and 5 minutes instead of just 5 minutes.
Can someone explain what could be the cause of this?
]]>Problem: If I posted an article on December 15th 2016 but I NOW I updated the same article today(July 20th 2017), when you view the article, the updated/modified date is never shown to the user.
NOTE: I did google it and I am able to display the modified date thanks to articles on WPBeginner etc BUT, how do I only post ONE? If the post is updated, it should post JUST the new modified date/time, not both.
I was leaning towards IF and ELSE statements but I can’t figure out how to set it up like this…
*** If post was modified, post modified date, else post date it was published. ***
If someone can please help me out here, I would appreciate it a lot, I am lost, thanks!
]]>First of all, thanks for a lovely plug-in, it’s very useful.
Secondly, I had some problems getting the post-date into the <h3>-tag and I found a solution:
change this code on line 91:
if (!empty($date))
echo '<h3 class="date">'.the_time($date).'</h3>';
to:
if (!empty($date))
echo '<h3 class="date">'.get_the_time($date, $post).'</h3>';
I hope this helps
https://www.ads-software.com/plugins/recent-posts-with-excerpts/
]]>This function work perfectly in a single.php and return me the data in Italian.
I have WP in Italian and setup data in admin page with time zone Rome.
This function don’t work in archive.php and return me the data in English.
Example:
single.php: 24 maggio 2013
archive.php 24 May 2013
you have any idea to solve this???
Thanks.
]]>Currently i’m using a child template for my news section which have same code as archive.php and the code is listed below. The problem is with the dates and posts that are listed for the news and archive. They were differenta and I want the latest archive to be shown for both pages.
here is the link and you can understand what i want.
News page:
https://iintellect.co.uk/demo-server/olaff/?page_id=8
Archive Page:
https://iintellect.co.uk/demo-server/olaff/?m=201304
The archive pages are correct but the child template is wrong.
Any Idea?
<?php wp_get_archives( array( 'type' => 'monthly', 'limit' => 10 ) ); ?>
</div>
</div>
<div class="large-12 columns">
<div class="row">
<div class="large-4-news columns">
<?php
$archive_year = get_the_time('Y');
$archive_month = get_the_time('m');
$archive_day = get_the_time('d');
$previous_day= $archive_day-1;
$prev2_day= $archive_day-2;
?>
<?php $args = array(
'year' => $archive_year,
'monthnum' => $archive_month,
'day' => $archive_day
);
query_posts( $args ); ?>
<div class="panel">
<h5><?php the_time('j. F'); ?></h5>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<p><a>"><?php the_title(); ?></a></p>
<p><a>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'news-thumb' ); } ?></a></p>
<p><?php echo string_limit_words(get_the_excerpt(), 15); ?></p>
<?php endwhile; else: ?>
<p><?php _e('No posts for this day'); ?></p>
<?php endif; ?>
</div>
<?php wp_reset_query(); ?>
</div>
[Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
Thanks in advance
]]>notice that the dates on the home page all say Jan 1 2013.
Here’s the code for the home page excerpt. What am I doing wrong?
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php } ?>
<?php foreach((get_the_category()) as $label) { //Displays the category label at the top of each post
echo '<h3 class="category-label">' . $label->cat_name . '</h3>';
}
?>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<div class="bf-date">
<?php echo '<p class="excerpt-date">' . get_the_time('M n, Y') . '</p>';
?>
</div><!-- .bf-date -->
]]>I am trying to get a timestamp to show up on my posts. Keep in mind that I’m in Sweden which means I have WordPress set to Stockholm as my timezone (UTC+1). Currently I’m going with this code to echo the post timestamp into my theme:
<?php
echo str_pad(get_the_time('Y'),5,'0',STR_PAD_LEFT).'-'.get_the_time('m-d\TH:i:sP');
?>
To test this I created a new post. WordPress tells me it has been published at ~15:32. So I would expect to get the following time displayed:
02010-02-13T15:32:??+01:00
(The question marks are there because WordPress does save the seconds but doesn’t show them at the publishing page.)
But this is not the result I’m getting. My theme is giving me this:
02010-02-13T15:32:20+00:00
As you can see it gives me a timezone offset of 0. I don’t remember living in UTC time.
So I went back to my general settings to check on the timezone. There seem to be no problems here, it even proofs to me that I’m not in UTC time by telling me this:
UTC time is 2010-02-13 14:37:15
Local time is 2010-02-13 15:37:15
So, how do I get WordPress to show the right offset?
]]>I am generating a list of pages using wp_list_pages. I would like to be able to automatically highlight NEW or RECENTLY UPDATED pages, perhaps by adding a new CSS class to them?
I looked into using get_the_time but haven’t a clue how to integrate that with wp_list_pages.
Any ideas or suggestions?
Thanks in advance,
Pete
]]>