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?

  • What do you want to change it to exactly? – Lodder Nov 21 '14 at 16:26
  • I want to change it to DD-MM-YYYY – RustyJoomla Nov 21 '14 at 16:27
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

  • I've tried this previously, but when saving from the component, the date is changed to 0000-00-00 in the component. – RustyJoomla Nov 21 '14 at 16:32
  • @RustyJoomla - Are you using Joomla 3.3.6? – Lodder Nov 21 '14 at 16:36
  • Yes, Joomla 3.3.6 – RustyJoomla Nov 21 '14 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 '14 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 '14 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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