WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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've created a custom profile field for my BP users and I'm looking to show the value on the user's profile page. The code below does this...

<?php bp_profile_field_data( array('user_id'=>get_the_author_meta( 'ID' ),'field'=>'birthday')); ?>

...But it displays it as "1985-10-30 00:00:00".

How can I format this to display like this: "October, 30 1985"

share|improve this question

closed as off-topic by toscho Aug 2 '14 at 20:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 2 down vote accepted

I have no idea if BuddyPress has built in date functions but WordPress does and PHP does. This should do it:

$bpress_date = bp_profile_field_data( array('user_id'=>get_the_author_meta( 'ID' ),'field'=>'birthday'));
// $bpress_date = "1985-10-30 00:00:00"; // test
echo date('F, j, Y',strtotime($bpress_date));

PHP's date expects UNIXTIME. That is why the date string is passed through strtotime. It does not work without that step.

You probably want to consider using WordPress' date_i18n, however, which would look like:

echo date_i18n(get_option('date_format'),strtotime($bpress_date));

This gives you some ability to internationalize things as the date will displayed according to the blog's date format settings.

share|improve this answer
Awesome, thank you. This worked perfectly. – Red Mar 24 '13 at 0:21

You would use the PHP function date() to format the birthday timestamp.


$birthday = bp_profile_field_data( array('user_id'=>get_the_author_meta( 'ID' ),'field'=>'birthday'));
echo date('F, j Y', $birthday);
//would result in October, 30 1985


share|improve this answer
Thanks for the reply, this only seemed to want to return the date "Jan 1, 1970" – Red Mar 24 '13 at 0:22

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