Search code examples
phpcodeigniterexpressionenginesafecracker

Expression Engine SafeCracker Formatting a Date Field format=”%d/%m/%Y” = 01/01/1970


Hi I am trying to format my date field which is called {member_birthday} with the format attribute. But whenever I apply the attribute to the tag it shows the date in the correct format but the with an incorrect date.

Code:

<input type="text" name="display_birthday" id="display_birthday" value="{member_birthday}" maxlength="23" size="25"/> 

Displays the correct date i.e 1982-11-08 12:00 AM

<input type="text" name="display_birthday" id="display_birthday" value="{member_birthday format="%d/%m/%Y"}" maxlength="23" size="25"/>

Displays an incorrect date i.e 01/01/1970


Solution

  • It seems the date format function does not work within a safecracker tag http://devot-ee.com/add-ons/support/zoo-visitor/viewthread/7449#25153, so I installed this plugin http://devot-ee.com/add-ons/nice-date and used this code

    {exp:low_nice_date date="{member_birthday}" format="%d/%m/%Y"}