So, on a first.php, I have <?php echo get_the_date('',$post->id); ?> to show the post date which, for example, shows "2 days ago."
Using the ajax, I am getting the post_id of the post via $_REQUEST['next_post'] then parsing it onto second.php
For the same post, I am using <?php echo get_the_date('',$_REQUEST['next_post']); ?> to get the date.
But the date simply shows as "46 years ago."
I am not sure why the date for the same post is different. Actually any posts loaded via ajax shows 46 years ago as the post publish date.
Does anyone know how to fix this?
Thanks!
$_REQUEST['next_post'] is probably empty. get_the_date uses unix time stamps that count seconds since 1970-01-01 00:00:00. Since you are posting null or 0 to get_the_date it will correctly display 46 years ago. Make sure $_REQUEST['next_post'] is set in the request header. You can use the chrome web tools to check if it is. Press ctrl + shift + j and select the network tab. There you can see your requests with all request data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With