timestamp and scheduled post irregularities
For starters try Core Control plugin to see if scheduled tasks are accurately assigned. Scheduled posts will show up as publish_future_post > check_and_publish_future_post() with post’s ID as argument.
For starters try Core Control plugin to see if scheduled tasks are accurately assigned. Scheduled posts will show up as publish_future_post > check_and_publish_future_post() with post’s ID as argument.
If you will write inside the console of your browser, then use one of a lot of helpers or use a small custom function in php. The follow function is easy to use and log inside the console of the browser. if ( ! function_exists( ‘debug_to_console’ ) ) { /** * Simple helper to debug … Read more
If it is the example in the timezone settings you’re referring to here: Then this is expected behaviour, and is correct by definition according to ISO standards, because this is not the time, it’s a timestamp. This way there is no ambiguity about the time being referenced, and it’s the only place in WordPress where … Read more
try $future_timestamp = strtotime(‘+1 week’, get_the_date(‘Y-m-d’)); echo date(‘Y-m-d’, $future_timestamp); or $future_timestamp = get_the_date(‘U’) + (60 * 60 * 24 * 7); echo date(‘Y-m-d’, $future_timestamp);
To print relative time on posts automatically we can use get_the_date filter. We will check the time difference and print it in human readable form. // Relative date & time function wp_relative_date() { return human_time_diff( get_the_time(‘U’), current_time( ‘timestamp’ ) ) . ‘ ago’; } add_filter( ‘get_the_date’, ‘wp_relative_date’ ); // for posts add_filter( ‘get_comment_date’, ‘wp_relative_date’ ); … Read more
You can use the PHP’s strtotime() and WordPress’s date_i18n() functions: function MY_FUNCTION( $input ) { // Removes commas so that we’ll get the proper timestamp. Otherwise, the // strtotime() function would return FALSE. $input = str_replace( ‘,’, ”, $input ); // Retrieve the UNIX timestamp of the date. $timestamp = @strtotime( $input ); // Returns … Read more
Take a look at current_time(). Returns the blog’s current local time in the specified format. There are two named formats: ‘mysql’ for MySQL/MariaDB’s timestamp data type format (i.e. YYYY-MM-DD HH:MM:SS), and ‘timestamp’ for the Unix timestamp format (i.e. epoch). Other strings will be interpreted as PHP date formats (e.g. ‘Y-m-d’) since 3.9.0. The optional secondary … Read more
You use a lowercase y for a 2 digit year. For example (l, F j, Y) –> returns, Friday, September 24, 2004 and (l, F j, y) —> returns Friday, September 24, 04
Here’s what I use: function oenology_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results(” SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status=”publish” “); $output=””; if($copyright_dates) { $copyright = “© ” . $copyright_dates[0]->firstdate; if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) { $copyright .= ‘-‘ . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; } Of course, if there’s a … Read more
You can use strtotime() to convert the time to an integer, and then do a conditional. // Get the current time $now = strtotime(“now”); // Convert post’s modification time to int $postUpdated = strtotime( $post->post_modified ); // Check if 3 hours has passed, each hour is 60*60 seconds if ( $now – $postUpdated >= 3*60*60 … Read more