本文整理汇总了PHP中format::datetime方法的典型用法代码示例。如果您正苦于以下问题:PHP format::datetime方法的具体用法?PHP format::datetime怎么用?PHP format::datetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类format
的用法示例。
在下文中一共展示了format::datetime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: benchmark
/**
* Benchmark
*
* @staticvar type $start
* @staticvar int $total
* @param string $name
*/
public static function benchmark($name = '')
{
if (self::$debug) {
static $start = NULL;
static $total = 0;
$benchmark = 0;
if (is_null($start)) {
$start = self::get_microtime();
} else {
$temp = self::get_microtime();
$benchmark = $temp - $start;
$start = $temp;
}
$total += $benchmark;
self::$data['benchmark'][] = ['name' => $name, 'time' => format::time_seconds($benchmark) . '', 'total' => format::time_seconds($total), 'start' => format::datetime($start), 'memory' => memory_get_peak_usage(true)];
}
}
示例2: render
/**
* Render widget
*
* @return mixed
*/
public function render()
{
$result = '';
// action bar
$result .= '<div style="text-align: right;">';
$result .= html::a(array('value' => html::icon(['type' => 'comment']) . ' ' . i18n(null, 'New'), 'href' => 'javascript:void(0);', 'onclick' => "numbers.frontend_form.trigger_submit('#form_numbers_frontend_html_widgets_comments_model_form_comment_form', false, true); numbers.modal.show('widgets_comments_{$this->widget_link}_comment');"));
$result .= '</div>';
$result .= '<hr class="simple" />';
// form
$pk = http_build_query2($this->options['pk']);
$js = <<<TTT
\t\t\tvar mask_id = 'widgets_comments_{$this->widget_link}_mask';
\t\t\t\$.ajax({
\t\t\t\turl: numbers.controller_full,
\t\t\t\tmethod: 'post',
\t\t\t\tdata: '__ajax=1&__ajax_form_id=widgets_comments_{$this->widget_link}_list&{$pk}',
\t\t\t\tdataType: 'json',
\t\t\t\tsuccess: function (data) {
\t\t\t\t\tif (data.success) {
\t\t\t\t\t\t\$('#widgets_comments_{$this->widget_link}_wrapper').html(data.html);
\t\t\t\t\t\teval(data.js);
\t\t\t\t\t\t// remove mask after 100 miliseconds to let js to take affect
\t\t\t\t\t\tsetTimeout(function() {
\t\t\t\t\t\t\t\$('#' + mask_id).unmask();
\t\t\t\t\t\t\t// we need to trigger resize to redraw a screen
\t\t\t\t\t\t\t\$(window).trigger('resize');
\t\t\t\t\t\t}, 100);
\t\t\t\t\t}
\t\t\t\t}
\t\t\t});
TTT;
$form = new numbers_frontend_html_widgets_comments_model_form_comment(['input' => $this->options['input'], 'no_actions' => true, 'bypass_hidden_values' => $this->options['pk'], 'other' => ['model' => $this->options['model'], 'pk' => $this->options['pk'], 'map' => $this->options['map']], 'on_success_js' => "numbers.modal.hide('widgets_comments_{$this->widget_link}_comment');" . $js]);
$body = $form->render();
$footer = html::button2(['name' => 'submit_comment', 'value' => i18n(null, 'Submit'), 'type' => 'primary', 'onclick' => "numbers.frontend_form.trigger_submit('#form_numbers_frontend_html_widgets_comments_model_form_comment_form', true); return false;"]);
$result .= html::modal(['id' => "widgets_comments_{$this->widget_link}_comment", 'class' => 'large', 'title' => i18n(null, 'Add Comment'), 'body' => $body, 'footer' => $footer]);
// list of comments in descending order
$where = [];
foreach ($this->options['map'] as $k => $v) {
$where[$v] = $this->options['pk'][$k];
}
$datasource = new numbers_frontend_html_widgets_comments_model_datasource_comments();
$data = $datasource->get(['model' => $this->options['model'], 'where' => $where]);
if (!empty($data)) {
$table = ['header' => ['id' => ['value' => '#', 'width' => '1%'], 'inserted' => ['value' => i18n(null, 'Date & Time'), 'width' => '1%', 'nowrap' => true], 'important' => ['value' => i18n(null, 'Important'), 'width' => '1%'], 'em_entity_name' => ['value' => i18n(null, 'Entity'), 'width' => '10%'], 'comment_value' => i18n(null, 'Comment')], 'options' => []];
$row_number = 1;
foreach ($data as $k => $v) {
// we need to hide old comments
$row_style = '';
if ($row_number > 10) {
$row_style = 'display: none;';
}
$table['options'][$v['id']] = ['id' => ['value' => $row_number . '.', 'row_style' => $row_style, 'row_class' => "widgets_comments_{$this->widget_link}_list_hiden " . ($v['important'] ? 'success' : null)], 'inserted' => format::datetime($v['inserted']), 'important' => ['value' => $v['important'] ? i18n(null, 'Yes') : ''], 'em_entity_name' => ['value' => $v['em_entity_name'], 'width' => '10%', 'nowrap' => true], 'comment_value' => nl2br($v['comment_value'])];
$row_number++;
}
$result_list = html::table($table);
// link to show all rows
$total_comments = count($data);
if ($total_comments > 10) {
$result_list .= '<div style="text-align: right;">' . html::a(['href' => 'javascript:void(0);', 'value' => i18n(null, '[count] comment(s) are hidden. Show all comments.', ['replace' => ['[count]' => $total_comments - 10]]), 'onclick' => "\$('.widgets_comments_{$this->widget_link}_list_hiden').show(); \$(this).hide();"]) . '</div>';
}
} else {
$result_list = html::message(['type' => 'warning', 'options' => [i18n(null, object_content_messages::no_rows_found)]]);
}
// if we are making an ajax call
if (!empty($this->options['input']['__ajax']) && ($this->options['input']['__ajax_form_id'] ?? '') == "widgets_comments_{$this->widget_link}_list") {
layout::render_as(['success' => true, 'error' => [], 'html' => $result_list, 'js' => ''], 'application/json');
}
// load mask
numbers_frontend_media_libraries_loadmask_base::add();
// put list into result
$result .= "<div id=\"widgets_comments_{$this->widget_link}_mask\"><div id=\"widgets_comments_{$this->widget_link}_wrapper\">" . $result_list . '</div></div>';
// wrap everything into segment
if (isset($this->options['segment'])) {
$temp = is_array($this->options['segment']) ? $this->options['segment'] : [];
$temp['value'] = $result;
$result = html::segment($temp);
}
// anchor
$result = html::a(['name' => "widgets_comments_{$this->widget_link}_anchor"]) . $result;
return $result;
}
示例3: render
/**
* Render
*
* @param string $type
* @return string
*/
public function render($type)
{
$result = '';
$session = new session();
// main switch
switch ($type) {
case 'pdf':
// document properties
$this->header['pdf']['orientation'] = isset($this->header['pdf']['orientation']) ? $this->header['pdf']['orientation'] : 'P';
$this->header['pdf']['unit'] = 'mm';
$this->header['pdf']['format'] = isset($this->header['pdf']['format']) ? $this->header['pdf']['format'] : 'LETTER';
$this->header['pdf']['encoding'] = isset($this->header['pdf']['encoding']) ? $this->header['pdf']['encoding'] : 'UTF-8';
$this->header['pdf']['font'] = isset($this->header['pdf']['font']) ? $this->header['pdf']['font'] : array('family' => 'helvetica', 'style' => '', 'size' => 8);
//include 'tcpdf/tcpdf.php';
// create new PDF document
$pdf = new TCPDF($this->header['pdf']['orientation'], $this->header['pdf']['unit'], $this->header['pdf']['format'], true, $this->header['pdf']['encoding'], false);
// set margins
$pdf->SetMargins(0, 0, 0);
$pdf->setPrintHeader(false);
// disable auto break
$pdf->SetAutoPageBreak(false, 0);
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// set color for background
$pdf->SetFillColor(255, 255, 255);
// set font
$pdf->SetFont($this->header['pdf']['font']['family'], $this->header['pdf']['font']['style'], $this->header['pdf']['font']['size']);
// stats
$page_counter = 1;
$page_y = 0;
$flag_new_page = true;
$flag_filter = true;
$flag_first_row = true;
$columns = array();
$all_columns = array();
// gethering all columns
foreach ($this->data as $k => $v) {
if ($v['t'] == 'columns') {
$all_columns[] = $v;
}
}
// looping through the data
foreach ($this->data as $k => $v) {
if ($v['t'] == 'columns') {
continue;
}
if ($flag_new_page) {
// add new page
$pdf->AddPage($this->header['pdf']['orientation'], '', true);
// drawing header
$pdf->MultiCell(40, 5, format::datetime(format::now()), 0, 'L', 1, 0, 5, 5, true, 0, false, true, 10, 'T');
// company + book name
$pw = $pdf->getPageWidth();
$pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
// todo: fix here
$pdf->MultiCell($pw - 90, 5, $session->company_name . ': ' . $session->book_name, 0, 'C', 1, 0, 40, 5, true, 0, false, true, 10, 'T');
// page counter
$pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
$pdf->MultiCell(40, 5, 'Page ' . $page_counter, 0, 'R', 1, 0, $pw - 45, 5, true, 0, false, true, 10, 'T');
// report name
$pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
$report_name = $this->header['name'] . ' (' . implode('-', application::get(array('mvc', 'controllers'))) . ')';
$pdf->MultiCell($pw - 10, 5, $report_name, 0, 'L', 1, 0, 5, 10, true, 0, false, true, 10, 'T');
if (isset($this->header['description'])) {
$pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
$pdf->MultiCell(205, 5, $this->header['description'], 0, 'L', 1, 0, 5, 15, true, 0, false, true, 10, 'T');
$page_y = 25;
} else {
$page_y = 20;
}
// if we need to add a filter
if ($flag_filter) {
if (isset($this->header['filter'])) {
foreach ($this->header['filter'] as $k2 => $v2) {
$pdf->SetFont($this->header['pdf']['font']['family'], 'B', $this->header['pdf']['font']['size']);
$pdf->MultiCell(50, 5, $k2 . ':', 0, 'L', 1, 0, 5, $page_y, true, 0, false, true, 10, 'T');
$pdf->SetFont($this->header['pdf']['font']['family'], '', $this->header['pdf']['font']['size']);
$number_of_cells = $pdf->MultiCell($pdf->getPageWidth() - 60, 5, $v2, 0, 'L', 1, 0, 55, $page_y, true, 0, false, true, 10, 'T');
if ($number_of_cells > 1) {
$page_y += 5 * ($number_of_cells - 1);
}
$page_y += 5;
}
}
$flag_filter = false;
// adding one line space
$page_y += 5;
}
// page counter
$page_counter++;
$flag_new_page = false;
}
// rendering rows
if ($flag_first_row) {
//.........这里部分代码省略.........
示例4: next_run_date
/**
* Next run datetime
*
* @param mixed $datetime
* @return string
*/
public function next_run_date($datetime = null)
{
$result = null;
if (empty($datetime)) {
$datetime = format::now('unix');
} else {
if (!is_numeric($datetime)) {
$datetime = strtotime($datetime);
}
}
$parts = format::datetime_parts($datetime);
for ($year = $parts['year']; $year <= self::$slot_stats[6]['max']; $year++) {
// check if we are in range
if (!(in_array('*', $this->parsed_expression['year']) || in_array($year, $this->parsed_expression['year']))) {
continue;
}
for ($month = 1; $month <= 12; $month++) {
// check if we are in range
if (!(in_array('*', $this->parsed_expression['month']) || in_array($month, $this->parsed_expression['month']))) {
continue;
}
for ($day = 1; $day <= 31; $day++) {
// check if we are in range
if (!(in_array('*', $this->parsed_expression['day']) || in_array($day, $this->parsed_expression['day']))) {
continue;
}
// check weekday
$weekday = date('w', mktime(0, 0, 0, $month, $day, $year));
if (!(in_array('*', $this->parsed_expression['weekday']) || in_array($weekday, $this->parsed_expression['weekday']))) {
continue;
}
// loop through hours
for ($hour = 0; $hour <= 23; $hour++) {
// check if we are in range
if (!(in_array('*', $this->parsed_expression['hour']) || in_array($hour, $this->parsed_expression['hour']))) {
continue;
}
// loop though minutes
for ($minute = 0; $minute <= 59; $minute++) {
$date = mktime($hour, $minute, 0, $month, $day, $year);
if ($date < $datetime) {
continue;
} else {
// check if we are in range
if (!(in_array('*', $this->parsed_expression['minute']) || in_array($minute, $this->parsed_expression['minute']))) {
continue;
}
// check the rest
$result = format::datetime($date);
goto exit1;
}
}
}
}
}
}
exit1:
return $result;
}