<p>Ok, I figured it out. First, to solve the birthday input problem, I used javascript to gather the values of each individual date dropdown and assemble them into a hidden text input that would be what passes in the datetime value to Craft.  No problem.</p>

<p>However, the datetime formatting tripped me up because there are two posts here that had the formatting differently.</p>

<p>The formatting needs to <em>exactly</em> match the example shown here on <a href="https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input" rel="nofollow">StraightUpCraft</a> under the date row.  So a date value like <code>2014-06-24</code> does not work; it needs to be <code>06/24/2014</code>. Likewise, the time value of <code>23:30:00</code> does not work either; it needs to be <code>11:30 PM</code>.</p>

<p>My final code looks like this after the javascript fills in the date value. Since it's a birthday, the 6pm time is just hardcoded in.</p>

<pre><code>&lt;input type="text" size="10" name="fields[birthday][date]" value="02/24/1985"&gt;
&lt;input type="text" size="10" name="fields[birthday][time]" value="6:00 PM"&gt;
</code></pre>

<p>Extra note for those using localized sites: you need to submit the date and time <em>exactly</em> how Craft formats them for each localization. For example, "6/24/2016" would be the acceptable date format for the U.S., but it will need to be "24.6.2016" when submitted on the German version of that page. You can output the formats dynamically in Craft using the translations filter:</p>

<pre><code>&lt;input type="text" size="10" name="fields[fieldHandle][date]" value="{{ now|date('Date Input Format'|t) }}"&gt;
&lt;input type="text" size="10" name="fields[fieldHandle][time]" value="{{ now|date('Time Input Format'|t) }}"&gt;
</code></pre>

<p>And then in your translations files put something like:</p>

<pre><code>"Date Input Format" =&gt; "d.m.Y",
"Time Input Format" =&gt; "G:i",
</code></pre>

<p>etc</p>

CC BY-SA 3.0
2016-03-02T12:23:33.907Z
2016-06-20T16:47:34.193Z
2016-06-20T16:47:34.193Z
Ryan
<p>Based on <a href="https://craftcms.stackexchange.com/a/471/12">this answer</a> to a similar question, I think you can use a date field within your Matrix and set the value using the following date format: <code>Y-m-d</code></p>

<p>Then you'd combine the three parts of the birthday (year, month, day format) into the value to be submitted. Do this via JS or you can use the HTML5 Date type (<a href="http://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_date" rel="nofollow noreferrer">example</a>) or some form of datepicker.</p>

<p>Note: Date type doesn't work with all browser so you'll need something like Modernizer, webshim and or jQuery/UI type fixes.</p>

<p>Here are a few places to learn more about how to use this with IE:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/22983013/how-to-get-html-5-input-type-date-working-in-firefox-and-or-ie-10">https://stackoverflow.com/questions/22983013/how-to-get-html-5-input-type-date-working-in-firefox-and-or-ie-10</a></li>
<li><a href="http://pietschsoft.com/post/2010/11/18/html5-day-5-new-date-input-type" rel="nofollow noreferrer">http://pietschsoft.com/post/2010/11/18/html5-day-5-new-date-input-type</a></li>
<li><a href="https://github.com/chemerisuk/better-dateinput-polyfill" rel="nofollow noreferrer">https://github.com/chemerisuk/better-dateinput-polyfill</a></li>
<li><a href="http://www.wufoo.com/html5/types/4-date.html" rel="nofollow noreferrer">http://www.wufoo.com/html5/types/4-date.html</a></li>
</ul>

CC BY-SA 3.0
2016-03-01T12:06:31.440Z
Thanks! I'm familiar with modernizer.  However, based on the current situation, I think I'll just write some js to put the dropdown values into the proper format and pass them in via a hidden input.  I think a datepicker is not ideal for birthdays because the date in the datepicker's popup is the current day and month, which causes a lot of editing on the user's part.
Ryan
CC BY-SA 3.0
2016-03-02T12:26:38.560Z
The formatting in your answer thread didn't work for me. Instead of `Y-m-d`, it had to be `m/d/Y`
Ryan
CC BY-SA 3.0
2016-02-25T17:58:53.437Z
2016-02-25T17:58:53.437Z
2017-05-23T12:38:53.957Z
Natetronn
<p>I was using a <a href="https://eonasdan.github.io/bootstrap-datetimepicker/" rel="nofollow noreferrer">date picker</a> instead of a drop-down menu to capture submissions. <a href="https://craftcms.stackexchange.com/questions/12724/how-can-i-set-the-postdate-and-expirydate-from-a-front-end-date-picker-via-plugi">Here is how I captured &amp; formatted</a> the date/time from the front-end to store as a dateTime field in the CP. </p>

<p>While not <em>exactly</em> the same, I think along with the answer @Natetronn provided and my example might help get the format correct.</p>

CC BY-SA 3.0
2016-03-01T11:59:48.567Z
I appreciate this, but a datepicker is not ideal UI for choosing a birthday because you will start on the current month of the current year.
Ryan
CC BY-SA 3.0
2016-02-25T20:32:53.630Z
2016-02-25T20:32:53.630Z
2017-04-13T12:51:00.253Z
Damon
<p>I'm using the wonderful <a href="https://github.com/am-impact/amforms" rel="nofollow">A&amp;M form plugin</a> to create a form on my site, and I have 3 dropdowns for the user's birthday: month, day, and year.  Currently, I have it set up so that when the form submits, those values get put into a matrix field when logged in the form submissions entry in the CMS.  I would prefer to have it put into a date/time field though, but I'm unsure how to do it.</p>

<p>This is the code in my form:</p>

<pre><code>&lt;label&gt;Birthday&lt;/label&gt;
&lt;input type="hidden" name="fields[birthday][new1][type]" value="date"&gt;
&lt;div id="birthday"&gt;
    &lt;select name="fields[birthday][new1][fields][month]"&gt;
        &lt;option selected="selected" value=""&gt;M&lt;/option&gt;
        {% for i in 1..12 %}
            &lt;option value="{{ i }}"&gt;{{ i }}&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;
    &lt;select name="fields[birthday][new1][fields][day]"&gt;
    &lt;option selected="selected" value=""&gt;D&lt;/option&gt;
        {% for i in 1..31 %}
            &lt;option value="{{ i }}"&gt;{{ i }}&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;
    &lt;select name="fields[birthday][new1][fields][year]"&gt;
        &lt;option selected="selected" value=""&gt;Year&lt;/option&gt;
        {% set startYear = now.year - 15 %}
        {% set endYear = now.year - 110 %}
        {% for i in startYear..endYear %}
            &lt;option value="{{ i }}"&gt;{{ i }}&lt;/option&gt;
        {% endfor %}
    &lt;/select&gt;
&lt;/div&gt;
</code></pre>

<p>In this case, "<strong>birthday</strong>" is my matrix field handle and "<strong>date</strong>" is the block type handle.  "<strong>month</strong>", "<strong>day</strong>", &amp; "<strong>year</strong>" are obviously the field handles within the matrix field.</p>

<p>There's nothing in the docs. I understand a date/time field doesn't produce an object like a matrix field, but I can't think of a solution of how to convert it.</p>

CC BY-SA 3.0
2016-02-25T17:44:54.190Z
This shows the format a front-end date/time field needs to be in. Does that help? http://craftcms.stackexchange.com/a/13601/57
Brad Bell
CC BY-SA 3.0
2016-03-01T19:59:06.347Z
Right, that link was more to show how I manipulated the data so it would get stored in the correct format.
Damon
CC BY-SA 3.0
2016-03-02T12:24:07.860Z
@BradBell thanks for that link. Ben Parizek's formatting worked for me.
Ryan
<form><datetime><plugin-amforms>
Create date/time from string via form
# Create date/time from string via form

(Asked by: username_0 on 2016-02-25)

I'm using the wonderful A&M form plugin to create a form on my site, and I have 3 dropdowns for the user's birthday: month, day, and year.  Currently, I have it set up so that when the form submits, those values get put into a matrix field when logged in the form submissions entry in the CMS.  I would prefer to have it put into a date/time field though, but I'm unsure how to do it.
This is the code in my form:
Birthday


    
        M
        {% for i in 1..12 %}
            {{ i }}
        {% endfor %}
    
    
    D
        {% for i in 1..31 %}
            {{ i }}
        {% endfor %}
    
    
        Year
        {% set startYear = now.year - 15 %}
        {% set endYear = now.year - 110 %}
        {% for i in startYear..endYear %}
            {{ i }}
        {% endfor %}
    


In this case, "birthday" is my matrix field handle and "date" is the block type handle.  "month", "day", & "year" are obviously the field handles within the matrix field.
There's nothing in the docs. I understand a date/time field doesn't produce an object like a matrix field, but I can't think of a solution of how to convert it.

**Tags:** form, datetime, plugin-amforms
> **Comments:**
> **username_1**: This shows the format a front-end date/time field needs to be in. Does that help? http://craftcms.stackexchange.com/a/13601/57  
> **username_2**: Right, that link was more to show how I manipulated the data so it would get stored in the correct format.  
> **username_0**: @BradBell thanks for that link. Ben Parizek's formatting worked for me.  

---

## 3 answers

### Answer by username_0 on 2016-03-02. Score: 2 | Accepted answer

Ok, I figured it out. First, to solve the birthday input problem, I used javascript to gather the values of each individual date dropdown and assemble them into a hidden text input that would be what passes in the datetime value to Craft.  No problem.
However, the datetime formatting tripped me up because there are two posts here that had the formatting differently.
The formatting needs to exactly match the example shown here on StraightUpCraft under the date row.  So a date value like 2014-06-24 does not work; it needs to be 06/24/2014. Likewise, the time value of 23:30:00 does not work either; it needs to be 11:30 PM.
My final code looks like this after the javascript fills in the date value. Since it's a birthday, the 6pm time is just hardcoded in.



Extra note for those using localized sites: you need to submit the date and time exactly how Craft formats them for each localization. For example, "6/24/2016" would be the acceptable date format for the U.S., but it will need to be "24.6.2016" when submitted on the German version of that page. You can output the formats dynamically in Craft using the translations filter:



And then in your translations files put something like:
"Date Input Format" => "d.m.Y",
"Time Input Format" => "G:i",

etc


---

### Answer by username_3 on 2016-02-25. Score: 1

Based on [this answer](https://craftcms.stackexchange.com/a/471/12) to a similar question, I think you can use a date field within your Matrix and set the value using the following date format: `Y-m-d`

Then you'd combine the three parts of the birthday (year, month, day format) into the value to be submitted. Do this via JS or you can use the HTML5 Date type ([example](http://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_date)) or some form of datepicker.

Note: Date type doesn't work with all browser so you'll need something like Modernizer, webshim and or jQuery/UI type fixes.

Here are a few places to learn more about how to use this with IE:

* <https://stackoverflow.com/questions/22983013/how-to-get-html-5-input-type-date-working-in-firefox-and-or-ie-10>
* <http://pietschsoft.com/post/2010/11/18/html5-day-5-new-date-input-type>
* <https://github.com/chemerisuk/better-dateinput-polyfill>
* <http://www.wufoo.com/html5/types/4-date.html>

> **Comments:**
> **username_0**: Thanks! I'm familiar with modernizer.  However, based on the current situation, I think I'll just write some js to put the dropdown values into the proper format and pass them in via a hidden input.  I think a datepicker is not ideal for birthdays because the date in the datepicker's popup is the current day and month, which causes a lot of editing on the user's part.  
> **username_0**: The formatting in your answer thread didn't work for me. Instead of `Y-m-d`, it had to be `m/d/Y`  

---

### Answer by username_2 on 2016-02-25. Score: 1

I was using a [date picker](https://eonasdan.github.io/bootstrap-datetimepicker/) instead of a drop-down menu to capture submissions. [Here is how I captured & formatted](https://craftcms.stackexchange.com/questions/12724/how-can-i-set-the-postdate-and-expirydate-from-a-front-end-date-picker-via-plugi) the date/time from the front-end to store as a dateTime field in the CP.

While not *exactly* the same, I think along with the answer @Natetronn provided and my example might help get the format correct.

> **Comments:**
> **username_0**: I appreciate this, but a datepicker is not ideal UI for choosing a birthday because you will start on the current month of the current year.  

---

