public function createdAgo(\DateTime $dateTime)
{
$delta = time() - $dateTime->getTimestamp();
if ($delta < 0)
throw new \InvalidArgumentException("createdAgo is unable to handle dates in the future");
$duration = "";
if ($delta < 60)
{
$time = $delta;
$duration = $time . " секунд" . (($time > 1) ? "ы" : "") . " назад";
}
else if ($delta <= 3600)
{
$time = floor($delta / 60);
$duration = $time . " минут" . (($time > 1) ? "ы" : "") . " назад";
}
else if ($delta <= 86400)
{
$time = floor($delta / 3600);
$duration = $time . " час" . (($time > 1) ? "ов" : "") . " назад";
}
else
{
$time = floor($delta / 86400);
$duration = $time . " дн" . (($time > 1) ? "ей" : "") . " назад";
}
return $duration;
}
{{ form_widget(form.birthday.day,{'attr': {'class':'name_class_style'}}) }}
{{ form_widget(form.birthday.month,{'attr': {'class':'name_class_style'}}) }}
{{ form_widget(form.birthday.year,{'attr': {'class':'name_class_style'}}) }}
public function createAction(Request $request)
{
$individualUser = new IndividualUser();
$iform = $this->createForm('BackendBundle\Form\IndividualUserType', $individualUser);
$iform->handleRequest($request);
$user = new User();
$form = $this->createForm('BackendBundle\Form\UserType', $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$individualUser->setUser($user->getId());
$em->persist($individualUser);
$em->persist($user);
$em->flush();
return $this->redirectToRoute('_user_index');
}
return $this->render('BackendBundle:User:create.html.twig',array(
'form' => $form->createView(),
'iform' => $oform->createView()
));
}