Symfony形成datetime以返回unix时间戳

i want to get the unix time using the symfony form

i tried with :

$form = $this->createFormBuilder()
        ->add(
            'source','text',array(
                'attr' => array('placeholder'=> 'z.B Hamburg',
                    'id'=> 'dirSource'),
                'label'=> false
            )
        )
        ->add('destination','text',array(
                'attr' => array('placeholder'=>'z.B Berlin',
                    'id'=> 'dirDirections'),
                'label'=> false
            )
        )
        ->add('time', 'datetime', array(
            'input'  => 'datetime',
            'data' => date_create(),
            'widget' => 'choice',
        ))
        ->add('Berechen','submit')
        ->getForm();
    $form->handleRequest($request);

$url2 = "https://maps.googleapis.com/maps/api/directions/json?origin=Berlin&destination=Hamburg&mode=transit&departure_time=".$timee."&key=" . $key;

I want to send the unix timestamp value to the google map.

But it returns array....

in the twig

{{ time|date('U') }}

I also tried with strtotime but it returns error

If you want the current time, use :

{{ "now"|date("U") }}

if time is a variable, your code is good except for the extra space before date() :

{{ time|date('U') }}

Update : following your clarifications, I think you want to use input => "timestamp" and not "datetime" in your form (see http://symfony.com/doc/current/reference/forms/types/datetime.html)