3

Currently using a date picker to select a date and submit it on user registration, formatted as m/d/Y, have played with various formats but can't one that works.

Any ideas?

  • Where exactly are you trying to save this date to? Can you please expand on what it is you are trying to achieve? – Ben Croker Jun 25 '14 at 14:50
  • This is just the standard front end user registration (based on the example in craft docs) with a couple of custom fields. All is working fine until I add a custom date field to the reg form, working on the assumption it fails on format. So i need to make sure that the input / post formats the date correctly. – Sam Hibberd Jun 25 '14 at 15:26
8

Craft stores dates in the database in the following format:

Y-m-d H:i:s

So submitting the date in this format should work, for example:

2014-06-24 23:30:00

It should also be possible to split the date and time into individual fields as follows:

<input type="text" name="fields[customFieldName][date]" value="2014-06-24" />
<input type="text" name="fields[customFieldName][time]" value="23:30:00" />
  • 1
    I've tried this with the split fields, and they do not work - nothing is stored in the date-time field in the back end. If I take the same values and mung them into one input (following your example: <input type="text" name="fields[customFieldName]" value="2014-06-24 23:30:00" />) then it does work. Is this a bug I've found? – Matt Wilcox Jul 7 '17 at 7:50
  • Note, the format can vary between locales (apparently). See this Straight Up Craft post for an alternate syntax... straightupcraft.com/articles/… – Lindsey D Jun 5 '18 at 23:04

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.