3

In the extension I have used a date field, with the Field Type of Calendar (this uses the Joomla Date selector).

However, the date is being formatted to YYYY-MM-DD.

Any ideas?

2
  • What do you want to change it to exactly?
    – Lodder
    Nov 21, 2014 at 16:26
  • I want to change it to DD-MM-YYYY Nov 21, 2014 at 16:27

1 Answer 1

1

To change the way the date is formatted, you simply ass the format attribute to the field. As you want to change it to DD-MM-YY, you can use the following:

<field 
    name="calendar"
    type="calendar" 
    label="Select Date"
    default="21-11-2014"
    format="%d-%m-%Y"
/>

For more information on the calendar field type, please have a look at the following:

http://docs.joomla.org/Calendar_form_field_type

Hope this helps

8
  • I've tried this previously, but when saving from the component, the date is changed to 0000-00-00 in the component. Nov 21, 2014 at 16:32
  • @RustyJoomla - Are you using Joomla 3.3.6?
    – Lodder
    Nov 21, 2014 at 16:36
  • Yes, Joomla 3.3.6 Nov 21, 2014 at 16:37
  • 1
    Hmm odd. According to the docs, the format defines the way it's stored so it should work. I'll have a quick check
    – Lodder
    Nov 21, 2014 at 16:39
  • I've just tested this on a random module. Added the above code to the module's XML file, selected a date from the calendar, saved it, then echoed the value in the default.php and it works fine.
    – Lodder
    Nov 21, 2014 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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