Welcome, Guest
Username: Password: Remember me

TOPIC: Changing date format in FORMS

Changing date format in FORMS 29 Dec 2011 17:07 #770

  • sirkile
  • sirkile's Avatar
  • Offline
  • New Member
  • Posts: 1
  • Karma: 0
Hello,

When I switch the format of a date field to mm-dd-yyy from the default on an item form view, it will not load and an error is generated:

500 - DateTime::__construct() [datetime.--construct]: Failed to parse time string (12-27-2011) at position 0 (1): Unexpected character

Making the same change on a listing view loads successfully.

I've dug through all the code several times and I just can't seem to pick out where the issue is.

EDIT: One additional piece of information, it appears to only occur when the day/date is above 12, which would seem to indicate it is getting the day and month values confused.
Last Edit: 29 Dec 2011 17:14 by sirkile. Reason: Add additional piece of information.
The administrator has disabled public write access.

Changing date format in FORMS 30 Dec 2011 16:33 #775

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes, of course.

Because the post send only string values, so if you change the format of displaying, it also change the format in the post array.

The string value in the post is interpreted and decoded from its right format.

TODO :
If you want to make such changes, you have to modify source code in the table php file, in the check() method.

I didn't tried in your project, but let first try this, and tell me if you still have problem.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Changing date format in FORMS 10 Feb 2012 02:35 #1221

  • jrussell
  • jrussell's Avatar
  • Offline
  • New Member
  • Posts: 1
  • Karma: 0
:(
I had the same issue but was able to get it to work when I changed the format to yyyy-mm-dd. It was a little frustrating in that I really want to use the mm-dd-yyyy format.
The administrator has disabled public write access.

Re: Changing date format in FORMS 12 Feb 2012 11:57 #1242

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
It is a Jooma! issue.


try theses :

echo(JHTML::_('calendar','2012-02-23','date','date','%Y-%m-%d'));   //OK
echo(JHTML::_('calendar','23-02-2012','date','date','%d-%m-%Y')); //OK
echo(JHTML::_('calendar','23-02-12','date','date','%d-%m-%y')); //OK


echo(JHTML::_('calendar','23/02/2012','date','date','%d/%m/%Y'));   //FAILS
echo(JHTML::_('calendar','02-23-2012','date','date','%m-%d-%Y')); //FAILS

I looked in Joomla and I cannot propose you a fix now.
The idea could be a JS script to corrupt the calendar, but the best is that issue should be solved in next releases of Joomla.

EDIT : In Joomla 1.5, it is working nice.

(Try to do the same above tests on Joomla 1.5)
Coding is now a piece of cake
Last Edit: 13 Feb 2012 14:22 by admin.
The administrator has disabled public write access.

Re: Changing date format in FORMS 13 Feb 2012 14:35 #1271

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
media/system/js/calendar.js
media/system/js/calendar-setup.js


and

media/system/js/calendar-uncompressed.js
media/system/js/calendar-setup-uncompressed.js


are the files you have to understand and modify.

There is a parameter for the date format in the configuration you can hack,
This parameter doesn't seems well linked to the JHTML::(calendar) of Joomla.


Not tested and not digged more.
... Who try to continue searching ?

The calendar website is here :
www.dynarch.com/projects/calendar/download/

Didn't submitted to the Joomla Team.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.080 seconds

Get Started