PHP : Get all Timezones

<?php

$tzlist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);

foreach($tzlist as $val){

$date = new DateTime(date(‘Y-m-d H:i:s’), new DateTimeZone($val));
$tz[] = $date->format(‘P’);
echo $val .” == “. $date->format(‘P’);

}

//print_r(array_unique($tz));

$date = new DateTime(date(‘Y/m/j H:i:s’), new DateTimeZone(‘Asia/Kolkata’));
echo $date->format(‘Y/m/j H:i:sP’) . “<br/>”;

$timezone  = “+05:30”;
echo gmdate(“Y/m/j H:i:s”, time() + 3600*($timezone+date(“I”)));

ZF2 : get HTML of View

protected function hasGridPdfRequest() {
$param = $this->params()->fromQuery(‘pdf’, “”);

if (trim($param) == “download”) {
$session = new \Zend\Session\Container(‘session’);

$viewRenderer = $this->getServiceLocator()->get(‘Zend\View\Renderer\RendererInterface’);
$layoutViewModel = $this->layout();
$layoutViewModel->setTemplate(‘layout/pdflayout’);
$route = ConstantFunction::getCurrentRoute();
$data = array();

if (isset($session->gridpdf[$route][‘sql’]) && trim($session->gridpdf[$route][‘sql’]) != “”) {
$connection = $this->getEntityManager()->getConnection();
$sql = isset($session->gridpdf[$route][‘sql’]) ? $session->gridpdf[$route][‘sql’] : “”;
$param = !empty($session->gridpdf[$route][‘param’]) ? $session->gridpdf[$route][‘param’] : array();
$data = $connection->executeQuery($sql, $param)->fetchAll();
}
$viewModel = new ViewModel(array(
‘data’ => $data
));

$viewModel->setTemplate($this->pdfPath);

//            $layoutViewModel->setVariables(array(
//                ‘content’ => $viewRenderer->render($viewModel),
//            ));
//
//            $htmlOutput = $viewRenderer->render($layoutViewModel);
$htmlOutput = $viewRenderer->render($viewModel);
return $this->downloadPdf($htmlOutput);
}

ZF2 : Error Log

  1. Goto Module.php and add the event
public function onBootstrap(MvcEvent $e) {
 $applicaton = $e->getApplication();
 $serviceManager = $applicaton->getServiceManager();
 $this->flash = $serviceManager->get('ControllerPluginManager')->get('flashMessenger');

$eventManager->attach(MvcEvent::EVENT_DISPATCH, array(
 $this,
 'beforeDispatch'
 ), 100);

$eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'dispatchError'));
 $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'dbConnectionError'), 1000);

}

Continue reading