Skip to content

Instantly share code, notes, and snippets.

@morontt
Created May 8, 2014 09:15
Show Gist options
  • Save morontt/927cce06603936a36b5c to your computer and use it in GitHub Desktop.
Save morontt/927cce06603936a36b5c to your computer and use it in GitHub Desktop.
Facepalm (current timestamp)
<?php
/**
* Created by PhpStorm.
* User: morontt
* Date: 08.05.14
* Time: 12:15
*/
namespace Ultrasoft\SuperBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class GeniusController extends Controller
{
/**
* @return Response
*/
public function indexAction()
{
$currentTimestamp = $this->getCurrentTimestamp();
return $this->render(
'UltrasoftSuperBundle:Genius:index.html.twig',
array(
'timestamp' => $currentTimestamp,
)
);
}
/**
* @return string
*/
private function getCurrentTimestamp()
{
$em = $this->container->get('doctrine')->getEntityManager();
$rez = $em->getConnection()->fetchAssoc('SELECT CURRENT_TIMESTAMP() as current_datetime;');
return $rez['current_datetime'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment