Convert a date to ISO8601 date format

Use the_time or get_the_time, which accept the same format parameters as php’s date. // assign to a variable $iso8601_date = get_the_time(‘c’); // or output directly the_time(‘c’); EDIT- converting formats with php: $date = “September 11, 2011 9:00 am”; $time = strtotime( $date ); echo date( ‘c’, $time );

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

Query by custom dates in UNIX Time

PHP has a built-in date() function that formats Date-objects. In your case, you would use it as follows: echo date(‘Y’, 1322697600); Since you’re using these query arguments to build up an array of posts, and you want to filter specifically on that, I’d recommend building a function that triggers the loop based on your desired … Read more