Making Craft\DateTime Object from string in Twig I'm trying to use Craft's native datepicker with a plugin I've made for the admin section. 

I've got some code that works;

{% from "_includes/forms" import date %}

&lt;h3&gt;Start Date&lt;/h3&gt;

{{ date({
    id: 'startDate',
    name: 'startDate',
    value: now
}) }}


but I can't seem to get it to work with any other date, no matter what I do. 

In my URL I have;

startDate=09/02/2017


and in my twig template I have;

{% set startDate = craft.request.getParam('startDate') %}


What do I need to do to startDate in order to get the date picker to read that date?
Unfortunately, what you're trying to do, is not possible without writing a simple plugin to return a Craft\DateTime object that the day picker can work with.

The global variable now, is a Craft\DateTime object, which the date picker is happy to work with because it can call localeDate() on it.

However, anything returned by date or date_modify twig filters, will be a \DateTime object, which lacks functionality that the date picker relies on.

Your only option would be, to create a simple plugin that can take your date parameter, and return a Craft\DateTime object, which you can pass as a value to the date picker/date macro.

This is one of those things that you think, "this should be easy or at least possible", but I haven't found a twig-only solution yet.