php console log speed [closed]

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

Calculate future date

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);

Relative time – how to calculate difference beween post publish date and current time

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

How can I display the current time? [closed]

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

How do I create a dynamically-updated copyright statement?

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

If else statement based on date_diff value

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

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