當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Datetime::getOffset方法代碼示例

本文整理匯總了PHP中Datetime::getOffset方法的典型用法代碼示例。如果您正苦於以下問題:PHP Datetime::getOffset方法的具體用法?PHP Datetime::getOffset怎麽用?PHP Datetime::getOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Datetime的用法示例。


在下文中一共展示了Datetime::getOffset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionExportar

 public function actionExportar()
 {
     // get your HTML raw content without any layouts or scripts
     if (isset($_COOKIE['pcbuilder_cart'])) {
         $total = 0;
         $pcbuilder_cart = unserialize($_COOKIE['pcbuilder_cart']);
         if (count($pcbuilder_cart) > 0) {
             $pcbuilder_cart = Yii::$app->PCBuilder->array_sort($pcbuilder_cart, 'categoria', 'SORT_ASC');
             foreach ($pcbuilder_cart as $i => $peca) {
                 $modelPeca = Pecas::findOne($peca['peca']);
                 $pecas[] = ['id' => $modelPeca['id'], 'cookieID' => $i, 'nome' => $modelPeca['nome'], 'loja' => $modelPeca['loja'], 'link_externo' => $modelPeca['link_externo'], 'preco' => $modelPeca['preco'][0]['preco']];
                 $total = $total + $modelPeca['preco'][0]['preco'];
             }
         }
     } else {
         echo "Nada para salvar!";
         exit;
     }
     if (count($pecas) > 0) {
         $content = $this->renderPartial('_pdf', ['pecas' => $pecas, 'total' => $total]);
         $date = new \Datetime(null);
         $hoje = $date->getTimestamp() + $date->getOffset();
         // setup kartik\mpdf\Pdf component
         $pdf = new Pdf(['mode' => Pdf::MODE_BLANK, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_DOWNLOAD, 'content' => $content, 'filename' => 'PC Builder - Lista de Peças - ' . date("d.m.Y H.i.s", $hoje) . '.pdf', 'options' => ['title' => 'PC Builder - Lista de Peças - ' . date("d/m/Y H:i:s", $hoje), 'defaultheaderline' => 0, 'setAutoTopMargin' => 'stretch'], 'methods' => ['SetHeader' => ['' . '<table width="100%">' . '<tr>' . '<td width="75%"><a target="_blank" href="http://www.brunodeoliveira.com"><img width="100px" src="imgs/logo.png"></a></td>' . '<td width="25%" valign="bottom" style="text-align: right">Salvo em<br /><small>' . date("d/m/Y H:i:s") . '</small></td>' . '<tr/>' . '</table>' . ''], 'SetFooter' => ['Obrigado por utilizar o PC Builder - Desenvolvido por Bruno de Oliveira - Página {PAGENO}']]]);
         return $pdf->render();
     }
 }
開發者ID:brunofunny,項目名稱:pcbuilder,代碼行數:27,代碼來源:ConstruirController.php

示例2: diffDias

 public function diffDias($data)
 {
     $date = new \Datetime(null);
     $hoje = $date->getTimestamp() + $date->getOffset();
     $diff = strtotime($data) - $hoje;
     return floor($diff / (24 * 60 * 60));
 }
開發者ID:brunofunny,項目名稱:agob,代碼行數:7,代碼來源:AgobUtilsComponent.php

示例3: actionEventos

 public function actionEventos($from, $to)
 {
     $date = new \Datetime(null);
     $hoje = $date->getTimestamp() + $date->getOffset();
     $de = date("Y-m-d", $from / 1000);
     $para = date("Y-m-d", $to / 1000);
     $model = Eventos::find()->joinWith('atividade')->where(['>=', 'd_ini', $de])->orWhere(['<=', 'd_ter', $de])->orWhere(['<=', 'd_ter', $para])->andWhere(['atividades.empresa_id' => Yii::$app->session->get('empresa')])->all();
     $d = ['success' => 1];
     foreach ($model as $dados) {
         $d['result'][] = ['id' => $dados['id'], 'title' => $dados['atividade']['atividade'], 'url' => Url::to(['evento/visualizar', 'id' => $dados['id']]), 'class' => Yii::$app->AgobUtils->cssStatus($dados['status'], $dados['d_ter']), 'start' => strtotime($dados['d_ini']) . '000', 'end' => strtotime($dados['d_ter']) . '000', 'dias' => Yii::$app->AgobUtils->diffDias($dados['d_ter']), 'status' => $dados['status']];
     }
     echo json_encode($d);
 }
開發者ID:brunofunny,項目名稱:agob,代碼行數:13,代碼來源:DashboardController.php


注:本文中的Datetime::getOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。