How get exact time difference

human_time_diff() only returns a single {number} {unit} string back. It rounds to nearest whole unit, instead of breaking down the difference precisely. To get an exact duration difference, you’ll need to use your own function. As this is a popular need in PHP, there’s lots of solutions online – here’s a clever one I found: … Read more

How to amend time format of comments, using child-theme?

You have to return the formatted date string, the following will work: // define the get_comment_time callback function filter_get_comment_time( $date, $d, $gmt, $translate, $comment ) { $d = “g:i:s”; $date = mysql2date($d, $date, $translate); return $date; }; // add the filter add_filter( ‘get_comment_time’, ‘filter_get_comment_time’, 10, 5);

3 different times on my WordPress website

In short, the server shows 13h (correct in current time in São Paulo DST), but PHP shows15h and WordPress shows 12h. This is intentional, and needs additional clarification, but to expand you have: The server local time UTC timestamps Localised WP time These needs to be separate, e.g. if I host a Japanese website on … Read more

How do I make a page not visible at a certain time? [closed]

Take a look at this page https://codex.wordpress.org/Function_Reference/wp_update_post . There is an example of how to update the post. All you need is the post ID that you want to update, and some code to change certain text in the post.You will want to get the post’s data (an array), then change the $post_content array item … Read more

Recoverable Fatal Error – Object of class WP_Post could not be converted to string

the_title doesn’t work that way: the_title( $before, $after, $echo ); $before is the text that comes before the title, but you didn’t give it a string/text, you gave it a post object. Post objects aren’t strings, PHP doesn’t know what to do so it stops and prints an error instead. For the_title to work, you … Read more

Find hours between post_date and post_date_gmt

If all you need to do is check the difference, rather than display or modify anything, then you don’t need to do anything complicated with date_diff(). All you need to do is compare the number of seconds returned by get_post_time() for each date. get_post_time() returns the Unix timestamp for the date, which is simply the … Read more

How to have search results page sorted by post date

WordPress will order search results by newest post first by default, so if your results are in a different order then it looks like another plugin is affecting them. Have you tried searching with all other plugins disabled? If you’re using Relevanssi, then it won’t order results by date as Relvanssia overrides this with its … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)