0

I've created a Date fieldtype in Channel Fields and want to display this date in a Channel Form without the time. For example, 5/19/14 8:19 AM, I only want to display: 5/19/14.

I thought the EE date format would address this but it does not. If I add to my field tag {my_date format="%m/%d/%y"} the tag is displayed in the form, indicating some error. On the other hand if I add this to the form {current_time format="%m/%d/%y"} the date is displayed as I want.

So does the EE date format only apply to system dates, or is there a way to format the date fieldtype I created?

1 Answer 1

0

For the input field in Channel Form (would that be entry date or custom date field) you can only use the format of date defined in system preferences ("US" or "European").

Though I believe you can overcome that by applying your custom rules to jQuery Datepicker.

The "format" parameter is applicable when you display the date as text in rendered template, not for display of input field itself.

5
  • I tested the display as text and got the same result. I looked at $( "#mydate" ).datepicker({ dateFormat : 'mm/dd/yy', }); but it didn't remove the time. I'm not really sure where or how I would add this to my template. Feb 23, 2015 at 15:50
  • when you say "I tested the display as text and got the same result." - what exactly template code did you use and what was the output?
    – Yuri Salimovskiy
    Feb 23, 2015 at 15:59
  • The tag I use to display in my template is like <p> {my_date}</p> this displays the date and time. this <p> {my_date format="%m/%d/%y"}</p> displays no time but displays the tag as if it were a text text string as in {my_date format="%m/%d/%y"} Feb 23, 2015 at 18:42
  • You should definitely use format parameter for it. E.g. {my_date format="%Y-%m-%d"}
    – Yuri Salimovskiy
    Feb 23, 2015 at 18:44
  • This is definitely a js conflict with EE's datepicker, however I do not know how set the date format of the picker. By observation if my channel field short name is the same as my datepicker input name then the value stored in my channel entry is added to the input (along with the time). But if I try to set the input value with {my_date format="%m/%d/%y"} the datepicker input just echos out the tag. If I just use {my_date} date picker works, but with the time appended. I've tried without success. $(function() { $( "#my_date" ).datepicker(dateFormat : 'yy/mm/dd'); }); Feb 24, 2015 at 13:51

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.