Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

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
<?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

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.