How to get time difference between publish date and now?

Try the date_diff() / DateTime::diff() function in PHP: // Object-oriented style. $datetime1 = new DateTime( $post->post_date ); $datetime2 = new DateTime(); // current date $interval = $datetime1->diff( $datetime2 ); echo $interval->format( ‘%a days old’ ); // .. or procedural style. $datetime1 = date_create( $post->post_date ); $datetime2 = date_create(); // current date $interval = date_diff( $datetime1, … Read more

Finding difference in days

You should store the time as a unix time stamp then you can use human_time_diff to compare. echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ); If the difference is more than 24 hours difference it will return the value in days.

Echo Messages By Checking current_time()

You would just need to format the time that is returned by current_time() with the php date() function like this: $my_time = date(‘G’, current_time(‘timestamp’)); The param ‘G’ tells the function you just want to have the hour part (0 to 23) of the date. Have a look here: http://www.php.net/manual/en/function.date.php

Fixing UTC time – wordpress effects

WordPress essentially completely ignores native PHP date functionality, in favor of its own handling. That traditionally allowed it to manage related aspects (such as timezones and translation) with no regards for server configuration. My educated guess that it would be largely oblivious to such change. At most the cron tasks might fire in bulk and … Read more

How do I display posts by day?

You’d have to specify day, month, and year to get today’s posts: $my_query = new WP_Query( array( ‘cat’=>1, ‘year’=>date(‘Y’), ‘monthnum’=>date(‘m’), ‘day’=>date(‘d’), ‘posts_per_page’=>-1 ) ); Leaving day blank just doesn’t set that query var, so its not restricting your query at all.

Is it safe to use ‘date_default_timezone_set’ in plugin file?

http://codex.wordpress.org/Function_Reference/get_gmt_from_date Replace all instances of get_the_date or the_date with echo get_gmt_from_date(get_the_date(‘Y-m-d H:i:s’)). That’s not a quick fix, it’s a way to fix your sitemaps. EDIT: WordPress SEO runs it’s raw dates from MySQL through a WP function called mysql2date, which in turn calls date_i18n. date_i18n happens to have a handy filter which you can tie … Read more