Title: Date format year/month/date
Last modified: August 21, 2016

---

# Date format year/month/date

 *  Resolved [ahschoy](https://wordpress.org/support/users/ahschoy/)
 * (@ahschoy)
 * [12 years ago](https://wordpress.org/support/topic/date-format-yearmonthdate/)
 * Hi,
    I want to change the date format from datw/month/year to year/month/date.
   I edited bp-xprofile-custom-fields-type.php and changed the order of the sections
   of the code relating to the date. The date format in the edit mode appears to
   be correct, but in the actual registration form only the date is displayed. Can
   anyone help me please? Thanks
 * [https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [12 years ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948230)
 * I don’t understand. What field type are you using (datepicker, birthdate, …)?
   Give me some screenshots or url to see this? Can you explain a bit more please?
 *  Thread Starter [ahschoy](https://wordpress.org/support/users/ahschoy/)
 * (@ahschoy)
 * [12 years ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948233)
 * I am using birthdate. I have changed the date format to be yyyy/mm/dd in the 
   general setting. I tried to bp-xprofile-custom-fields-type.php file so that the
   order of the code is year, month then date. I am new to php programming and am
   not sure whether that was the right thing to do. After changing the php file 
   when I add new birthdate field to in the profile setup page the date was showing
   yyyy mm dd. After I saved the setting and view the profile in the actual site,
   only the drop down for the date appears, no month or year. I am testing in a 
   local development server so cannot send you the url. But what I am trying to 
   do is to change the date format so perhaps you can guide me through how to achieve
   this?
 * Thanks
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948235)
 * But what you need is to change the way the date is displayed when viewing profile
   info or do you need to change the way the dropdown boxes are displayed in profile
   form and registration form?
 * To do the first thing, you only have to modify the settings of date and hour 
   in general settings in wordpress admin.
 * If you want to change the way the form looks like, you will need to modify my
   plugin code. Search this function “bxcft_edit_render_new_xprofile_field”. The
   following code is responsible of displaying the 3 dropdowns boxes:
 *     ```
       // Dropdown => Day of month.
                       $options_day = '';
                       for ($i=1; $i<32; ++$i) {
                           $options_day .= sprintf('<option value="%s"%s>%s</option>',
                                                   $i,
                                                   selected($day, $i, false),
                                                   $i);
                       }
                       $input = sprintf('<select name="%s_day" id="%s_day"%s><option value=""%s>--</option>%s</select>',
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                               selected($day, '', false),
                                               $options_day); 
   
                       // Dropdown => Month.
                       $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
                       $months = array(
                           __( 'January', 'buddypress' ),
                           __( 'February', 'buddypress' ),
                           __( 'March', 'buddypress' ),
                           __( 'April', 'buddypress' ),
                           __( 'May', 'buddypress' ),
                           __( 'June', 'buddypress' ),
                           __( 'July', 'buddypress' ),
                           __( 'August', 'buddypress' ),
                           __( 'September', 'buddypress' ),
                           __( 'October', 'buddypress' ),
                           __( 'November', 'buddypress' ),
                           __( 'December', 'buddypress' )
                       );
                       $options_month = '';
                       for ($i=0; $i<12; ++$i) {
                           $options_month .= sprintf('<option value="%s"%s>%s</option>',
                                                   $eng_months[$i],
                                                   selected( $month, $eng_months[$i], false ),
                                                   $months[$i]);
                       }
                       $input .= sprintf('<select name="%s_month" id="%s_month"%s><option value=""%s>------</option>%s</select>',
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                               selected($month, '', false),
                                               $options_month);
   
                       // Dropdown => Year.
                       $birthdate_start_year = date('Y')-1;
                       $options_year = '';
                       for ($i=$birthdate_start_year; $i>1901; $i--) {
                           $options_year .= sprintf('<option value="%s"%s>%s</option>',
                                                   $i,
                                                   selected($year, $i, false),
                                                   $i);
                       }
                       $input .= sprintf('<select name="%s_year" id="%s_year"%s><option value=""%s>----</option>%s</select>',
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_is_required()?'aria-required="true" required="required"':'',
                                               selected($year, '', false),
                                               $options_year);
       ```
   
 * You only need to reorder like this and change two things:
 *     ```
       // Dropdown => Year.
                       $birthdate_start_year = date('Y')-1;
                       $options_year = '';
                       for ($i=$birthdate_start_year; $i>1901; $i--) {
                           $options_year .= sprintf('<option value="%s"%s>%s</option>',
                                                   $i,
                                                   selected($year, $i, false),
                                                   $i);
                       }
                       $input = sprintf('<select name="%s_year" id="%s_year"%s><option value=""%s>----</option>%s</select>',
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_is_required()?'aria-required="true" required="required"':'',
                                               selected($year, '', false),
                                               $options_year);
   
                       // Dropdown => Month.
                       $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
                       $months = array(
                           __( 'January', 'buddypress' ),
                           __( 'February', 'buddypress' ),
                           __( 'March', 'buddypress' ),
                           __( 'April', 'buddypress' ),
                           __( 'May', 'buddypress' ),
                           __( 'June', 'buddypress' ),
                           __( 'July', 'buddypress' ),
                           __( 'August', 'buddypress' ),
                           __( 'September', 'buddypress' ),
                           __( 'October', 'buddypress' ),
                           __( 'November', 'buddypress' ),
                           __( 'December', 'buddypress' )
                       );
                       $options_month = '';
                       for ($i=0; $i<12; ++$i) {
                           $options_month .= sprintf('<option value="%s"%s>%s</option>',
                                                   $eng_months[$i],
                                                   selected( $month, $eng_months[$i], false ),
                                                   $months[$i]);
                       }
                       $input .= sprintf('<select name="%s_month" id="%s_month"%s><option value=""%s>------</option>%s</select>',
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                               selected($month, '', false),
                                               $options_month);
   
                       // Dropdown => Day of month.
                       $options_day = '';
                       for ($i=1; $i<32; ++$i) {
                           $options_day .= sprintf('<option value="%s"%s>%s</option>',
                                                   $i,
                                                   selected($day, $i, false),
                                                   $i);
                       }
                       $input .= sprintf('<select name="%s_day" id="%s_day"%s><option value=""%s>--</option>%s</select>',
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_input_name(),
                                               bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                               selected($day, '', false),
                                               $options_day);
       ```
   
 * The first thing is the first “$input .=” of year box. The “.=” is saying concatenate
   this string to $input. Now, the year box is the first so we do not need to concatenate.
   We need to change:
    `$input .=` With: `$input =`
 * The second thing is before, the first “$input =” was day of month, now it’s the
   last box, so you need to concatenate to the previous $input. For day of month,
   we need to change:
    `$input =` With: `$input .=`
 * This is probably why you see only one box…
 *  Thread Starter [ahschoy](https://wordpress.org/support/users/ahschoy/)
 * (@ahschoy)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948237)
 * Thanks very much, that works.
    Could you please tell me which css I need to change
   to adjust the formatting of the displayed data?
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948259)
 * What css?
 *  Thread Starter [ahschoy](https://wordpress.org/support/users/ahschoy/)
 * (@ahschoy)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948261)
 * I asked this question in another thread:
    “I have added Sex (Male/Female) as 
   a radio button type and the label is right justified. If I change it to drop 
   down list box then the label is left justified consistent with other fields. 
   How can I change it left justified for radio button? Also, the selection Male
   and Female appear on 2 lines, can I change them to appear side by side on the
   same row?”
 * and this was your reply:
    “This field type is not from my plugin, it’s from xprofile
   extension of buddypress… To do this, you need to use css, all you want to do 
   is possible with css.”
 * I want to change the formatting of the buttons and date fields so am wondering
   where I should start.
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948285)
 * It depends on how your website is coded. I can’t say what css you need without
   seeing the page.
 *  Thread Starter [ahschoy](https://wordpress.org/support/users/ahschoy/)
 * (@ahschoy)
 * [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948286)
 * OK thanks. I will try and sort this out myself.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Date format year/month/date’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/buddypress-xprofile-custom-fields-
   type.svg)
 * [Buddypress Xprofile Custom Fields Type](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/)
 * [Active Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [ahschoy](https://wordpress.org/support/users/ahschoy/)
 * Last activity: [11 years, 12 months ago](https://wordpress.org/support/topic/date-format-yearmonthdate/#post-4948286)
 * Status: resolved