本文整理汇总了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();
}
}
示例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));
}
示例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);
}