WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the More Fields plugin which gives me the ability to create a date formatted YYYY/mm/dd and I want to convert that to be shown like: February 11, 2011

Is this possible?

share|improve this question
up vote 1 down vote accepted

Do you have issue with exactly converting or retrieval? Converting is trivial and is plain PHP:

date('F j, Y', strtotime($date));

For more complex and WordPress-specific way with localization support see date_i18n() function.

share|improve this answer
    
Rarst, this looks right but I am having trouble making it work 100%. $date = meta('event_date'); echo date('F j, Y', strtotime($date)); returns January 1 1970.... ideas? – tjsherrill Mar 15 '11 at 22:35
    
@tjsherrill ehm, I don't think meta() is native function?.. Are you sure you get sane string value in $date? – Rarst Mar 15 '11 at 22:40
    
I got it, meta(); is a template tag provided by the more-fields plugin. I simply used get_post_meta and it works great. thanks – tjsherrill Mar 18 '11 at 15:28
    
This isn't working for me. My custom field is "date-time-last" $date = get_post_meta('date-time-last'); echo date('l jS F Y', strtotime($date)); – Pete Apr 11 at 8:59
    
@Pete check the values you are getting and stuff, "isn't working" is a little vague. :) – Rarst Apr 11 at 9:29
<?php
$date = '2000/10/28';
$a = preg_split ( '/\//', $date );
echo date('F j, Y', mktime( 0, 0, 0, $a[1], $a[2], $a[0] ) );
share|improve this answer

This works for me (inside the loop)...

<?php $date = get_post_meta($post->ID, 'CUSTOM-FIELD-HERE', true); if($date != ''){echo date("l jS F Y", strtotime($date));} ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.