I’m trying to manipulate the output of WordPress’ the_date() function.
My code:
<?php
define('WP_USE_THEMES', false);
require('/gnews/wp-blog-header.php');
if (have_posts()) : while (have_posts()) : the_post();
$potatoes = the_date();
$themonth = substr($potatoes,3);
echo($themonth);
endwhile; else:
endif;
?>
Pardon the strange variable names, at wit’s end here.
No matter what I try, the above will only output June 17th 2011.
The end result I’d like is to set it up so that I have a three character month name in one variable, a two-digit date number in another variable, and the year in a third. The date has to be the date of the WordPress post however.
How would I do that?
Thanks!
If you wish these to be in 3 variables, pass the output of
the_date()intostrtotime()anddate('Y-M-d)and thenexplode()it into separate variables.strtotime()is perfectly capable of parsing a date likeJune 17th 2011.Update
WordPress’
the_date()‘s fourth parameter is a boolean which specifies whether to return or echo it. It isn’t necessary to usestrtotime()if done this way: