Change Date Format

  • Nico
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
9 years 8 months ago #48570 by Nico
Change Date Format was created by Nico
I need to change DATE FORMAT in OS registration form.

At the moment users add their birth date in this format: AAAA--MM-DD,
I need to change format in DD-MM-AAAA

In OS configuration page I have change "Date Format" option with "d-m-Y", but it doesn't work!

How can I change it?
Attachments:

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

More
9 years 8 months ago #48585 by ferrick
Replied by ferrick on topic Change Date Format
Hi Nico,

U can go to this folder /components/com_osmembership/libraries/rad/form/field -> date.php change the format.

From
return JHtml::_('calendar', $this->value, $this->name, $this->name, '%Y-%m-%d',".$attributes.");
To
return JHtml::_('calendar', $this->value, $this->name, $this->name, '%d-%m-%Y',".$attributes.");

Thanks.

Regards,
Ferrick Chan
The following user(s) said Thank You: Nico

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

More
9 years 8 months ago #48591 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Change Date Format
Many thanks Ferrick for helping me answer this support question :).

Tuan

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

More
9 years 6 months ago #51907 by mikek
Replied by mikek on topic Change Date Format
IMPORTANT !!
If you use the fix above, and replace '%Y-%m-%d' with '%m-%d-%Y', you will get an error in the backend when trying to edit a registrant who has registered for an event.
You'll see this error:
An error has occurred.
0 DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: Failed to parse time string (11-29-2014) at position 0 (1): Unexpected character

The error is because Mysql doesn't recognize (ex. 10-31-2014) this as a valid date type. You have to add slashes /, not hyphens.

SOLUTION:
Code:
Use this format: '%m/%d/%Y'
*notice the new format is like 10/31/2014 (not 10-31-2014)

Hope this helps someone.

Mike

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

More
9 years 6 months ago #51916 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Change Date Format
Thanks Mike. Infact, it is PHP could not recognize the format and throw the error. I will try to think more about it and try to find a permanent solution and add support for it in the core of the extension

Regards,

Tuan

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