Date format on custom fields

  • abarrow
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
12 years 3 months ago #24308 by abarrow
Date format on custom fields was created by abarrow
I looked around in the forum but couldn't see anything on this.

I have a custom field for Date of Birth, which I assigned as a "Date Time" field.

I also selected the correct (I think) PHP date format string in configuration, which is "j/n/Y".

When I select dates using the calendar pop-up on that field, I expect to see dates in the format DD/MM/YYYY.

What I see are dates in the format YYYY-MM-DD. I haven't looked in the database yet, but the same format comes up on the registration confirmation page. If I manually type in the date in the DD/MM/YYYY format, that's what shows on the confirmation page.

Is there a way that I can force the calendar pop-up to give me the right format?

Thanks.

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #24389 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Date format on custom fields
Hi

Unfortunately, with the date format for the datetime custom field, we will have to use the format YYYY-MM-DD so that it can be saved properly to database. You cannot change it.

Tuan

Please Log in or Create an account to join the conversation.

  • abarrow
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
12 years 3 months ago #24397 by abarrow
Replied by abarrow on topic Re: Date format on custom fields
Okay Tuan, thanks. I'll work around it!

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago - 12 years 3 months ago #24401 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Date format on custom fields

abarrow wrote: Okay Tuan, thanks. I'll work around it!


Could you please try the solution below :

1. Open the file components/com_eventbookings/helper/fields.php

2. Find the function _renderDateTime(&$row)

3. Find the code below inside that function :
Code:
<?php echo JHTML::_('calendar', $row->default_values, $row->name, $row->name) ; ?>

4. Change it to :
Code:
<?php echo JHTML::_('calendar', $row->default_values, $row->name, $row->name, '%d/%m/%Y') ; ?>

Tuan
Last edit: 12 years 3 months ago by Tuan Pham Ngoc.

Please Log in or Create an account to join the conversation.

  • abarrow
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
12 years 3 months ago #24414 by abarrow
Replied by abarrow on topic Re: Date format on custom fields
Worked great! Thanks!!!!!

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #24415 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Date format on custom fields
Great. Thanks for confirming :).

Tuan

Please Log in or Create an account to join the conversation.

  • abarrow
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
12 years 3 months ago - 12 years 3 months ago #25220 by abarrow
Replied by abarrow on topic Re: Date format on custom fields
I was still having a problem, but now it has gone away. Just deleted my previous message.
Last edit: 12 years 3 months ago by abarrow. Reason: Problem seems to have fixed itself.

Please Log in or Create an account to join the conversation.

  • abarrow
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
12 years 3 months ago #25399 by abarrow
Replied by abarrow on topic Re: Date format on custom fields
Well, I guess I'm just going to have to go to separate fields for Day, Month and Year. It will look like crap, but the Date field isn't working consistently - sometimes it displays correctly, other times it doesn't, and when people enter dates in the format I specify, I just get an error when I try to view the registrant. Since I can't validate the date, the entry is basically useless for any sort of future date calculation.

Very disappointing.

Please Log in or Create an account to join the conversation.

More
12 years 3 months ago #25401 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: Date format on custom fields
Are you in rush ? If not, can you contact me on Skype so that we can check it together when I come back to office this weekend (I am still at my home for new year holiday and the internet connection is very bad now).

Tuan

Please Log in or Create an account to join the conversation.

  • abarrow
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
12 years 3 months ago #25403 by abarrow
Replied by abarrow on topic Re: Date format on custom fields
I think I'll just leave it the way it is with three separate fields for day, month and year. Date of birth is critical in our event, and this way I can be sure that we have it in the right format. We are starting to get a lot of registrations for our event, so I really don't want to make any more big changes.

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc