<p>In the end I switched it to a default text field and used jQuery datepicker.</p>

CC BY-SA 3.0
2017-11-30T01:34:24.403Z
This is the simplest solution. If you were to expand the Field dropdown it would show the Date/Time field in a 'Custom Fields' dropdown. Custom Fields require that you either write an integration to add support or update your base templates with custom HTML to handle the DateTime field.
Ben Parizek
CC BY-SA 3.0
2017-11-28T00:19:34.323Z
2017-11-28T00:19:34.323Z
CreateSean
<p>Not exactly a direct answer, but this is where my first search started me.</p>

<p>To save a Date/Time field into craft using a jQuery dateTime picker, you can create a small plugin and place this in the <code>init</code> method of the primay plugin file (Craft 2x).</p>

<p><strong>MyPluginFile.php</strong></p>

<pre><code>public function init()
{
    parent::init();

    craft()-&gt;on('sproutForms.onBeforeSaveEntry', function (Event $event) {
        if (craft()-&gt;request-&gt;isCpRequest()) {
            // Entry was saved from within the CP so we can ignore it.
        } else {
            if ($event-&gt;params['isNewEntry']) {
                $entry = $event-&gt;params['entry'];

                // Get the current time zone from the system.
                date_default_timezone_set(craft()-&gt;timezone);

                $entry-&gt;setContentFromPost(array(
                    'eventDate' =&gt; date('Y-m-d', strtotime(craft()-&gt;request-&gt;getPost('fields.eventDate'))),
                    'startTime' =&gt; date('Y-m-d H:i:s', strtotime(craft()-&gt;request-&gt;getPost('fields.startTime'))),
                    'endTime' =&gt; date('Y-m-d H:i:s', strtotime(craft()-&gt;request-&gt;getPost('fields.endTime'))),
                ));
            }
        }
    });
}
</code></pre>

CC BY-SA 4.0
2018-08-12T03:17:16.683Z
2018-08-13T13:42:57.107Z
2018-08-13T13:42:57.107Z
Damon
<p>I'm working on an inherited site where I have a sprout form and am adding additional fields. I have added a date/time field to the form with the settings in this screenshot.</p>

<p><a href="https://i.sstatic.net/WGZsi.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WGZsi.jpg" alt="enter image description here"></a></p>

<p>In my template where all other fields are working I have added the following.</p>

<p>{{ craft.sproutForms.displayField('contact.targetProjectDate') }}</p>

<p>This field does not display and there is nothing in the source either.</p>

<p>Please advise</p>

<form><datetime><plugin-sproutforms>
Sprout Form Date/Time field not displaying
# Sprout Form Date/Time field not displaying

(Asked by: username_0 on 2017-11-23)

I'm working on an inherited site where I have a sprout form and am adding additional fields. I have added a date/time field to the form with the settings in this screenshot.

[![enter image description here](https://i.sstatic.net/WGZsi.jpg)](https://i.sstatic.net/WGZsi.jpg)

In my template where all other fields are working I have added the following.

{{ craft.sproutForms.displayField('contact.targetProjectDate') }}

This field does not display and there is nothing in the source either.

Please advise

**Tags:** form, datetime, plugin-sproutforms


---

## 2 answers

### Answer by username_0 on 2017-11-28. Score: 1 | Accepted answer

In the end I switched it to a default text field and used jQuery datepicker.

> **Comments:**
> **username_1**: This is the simplest solution. If you were to expand the Field dropdown it would show the Date/Time field in a 'Custom Fields' dropdown. Custom Fields require that you either write an integration to add support or update your base templates with custom HTML to handle the DateTime field.  

---

### Answer by username_2 on 2018-08-12. Score: 0

Not exactly a direct answer, but this is where my first search started me.
To save a Date/Time field into craft using a jQuery dateTime picker, you can create a small plugin and place this in the init method of the primay plugin file (Craft 2x).
MyPluginFile.php
public function init()
{
    parent::init();

    craft()->on('sproutForms.onBeforeSaveEntry', function (Event $event) {
        if (craft()->request->isCpRequest()) {
            // Entry was saved from within the CP so we can ignore it.
        } else {
            if ($event->params['isNewEntry']) {
                $entry = $event->params['entry'];

                // Get the current time zone from the system.
                date_default_timezone_set(craft()->timezone);

                $entry->setContentFromPost(array(
                    'eventDate' => date('Y-m-d', strtotime(craft()->request->getPost('fields.eventDate'))),
                    'startTime' => date('Y-m-d H:i:s', strtotime(craft()->request->getPost('fields.startTime'))),
                    'endTime' => date('Y-m-d H:i:s', strtotime(craft()->request->getPost('fields.endTime'))),
                ));
            }
        }
    });
}


---

