Converting a date format from a custom field
-
Hi, I got some “custom posts” set for events and I am ordering the events by the input date in a “custom field” in Year/Month/Day format.
I’d like to convert the output of that format to “06 February 2011”, for example, in the frontend.
I am triyng this but it doesn’t work
<?php
$todaysDate = date('Y/m/d');// Get today's date in the right format
$agendaloop = new WP_Query('post_type=agenda&posts_per_page=10&meta_key=_date&meta_compare=>&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');$display_date = date('d F, Y', strtotime(get_post_meta($post->ID, "_date", true)));
?>Than in the “loop” I got this for the output:
<?php echo $display_date; ?>
I get 01 January 1970 for all the posts. I know that this is the start date for “strtotime”, but what’s wrong with the code?
- The topic ‘Converting a date format from a custom field’ is closed to new replies.