0

I have a Symfony2 application which receive a JSON data in a form. One of the field is a date time. If I renderize the field form in this way:

->add('startDate', 'date', array(
        'widget' => 'single_text',
        'format' => 'yyyy-MM-dd HH:mm:ss'))

This accept something like:

"startDate": "2015-05-03 12:30:00"

But I need to introduce a datetime in this way:

"startDate": "2015-05-12T15:43:00+0200"

How can I set this format in the field?

1 Answer 1

3

On http://php.net/manual/en/function.date.php

"c" => ISO 8601 date (added in PHP 5) => 2004-02-12T15:19:21+00:00

Try this:

->add('startDate', 'date', array(
    'widget' => 'single_text',
    'format' => 'c'))

I hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.