当前位置: 首页>>代码示例>>PHP>>正文


PHP date_format函数代码示例

本文整理汇总了PHP中date_format函数的典型用法代码示例。如果您正苦于以下问题:PHP date_format函数的具体用法?PHP date_format怎么用?PHP date_format使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了date_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toDate

 /**
  * Converts a MySQL formatted date (Y-m-d) to AVETMISS format (dmY).
  *
  * @param string $mysql
  *
  * @return string
  */
 public static function toDate($mysql = null)
 {
     if (is_null($mysql)) {
         return null;
     }
     return date_format(new DateTime($mysql), 'dmY');
 }
开发者ID:bluedogtraining,项目名称:avetmiss,代码行数:14,代码来源:Utilities.php

示例2: __invoke

 /**
  * invoke
  */
 public function __invoke($datetime)
 {
     if ($datetime != null) {
         return date_format($datetime, \TmCommon\Config\Config::DATE_TIME_FORMAT);
     }
     return null;
 }
开发者ID:vn00186388,项目名称:bibo-test,代码行数:10,代码来源:DateTime.php

示例3: __construct

 /**
  * __construct Contructor that prepare the collection for assign product list
  * @var Int $userId Current logged seller id
  * @var String $filter Search query string
  * @var String $filter_prostatus product status query string
  * @var String filter_data_frm product creation from date query string
  * @var String filter_data_to product creation to date query string
  * @var Object $collection Catalog product collection object
  * @var Array $products Catalog product ids
  * @var Object $collection Assign product collection object
  */
 public function __construct()
 {
     parent::__construct();
     $userId = Mage::getSingleton('customer/session')->getCustomerId();
     $filter = $this->getRequest()->getParam('s') != "" ? $this->getRequest()->getParam('s') : "";
     $filter_prostatus = $this->getRequest()->getParam('prostatus') != "" ? $this->getRequest()->getParam('prostatus') : "";
     $filter_data_frm = $this->getRequest()->getParam('from_date') != "" ? $this->getRequest()->getParam('from_date') : "";
     $filter_data_to = $this->getRequest()->getParam('to_date') != "" ? $this->getRequest()->getParam('to_date') : "";
     $from = null;
     $to = null;
     if ($filter_data_to) {
         $todate = date_create($filter_data_to);
         $to = date_format($todate, 'Y-m-d H:i:s');
     }
     if ($filter_data_frm) {
         $fromdate = date_create($filter_data_frm);
         $from = date_format($fromdate, 'Y-m-d H:i:s');
     }
     $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addFieldToFilter('name', array('like' => "%" . $filter . "%"))->setOrder('entity_id', 'AESC');
     $products = array();
     foreach ($collection as $data) {
         array_push($products, $data->getEntityId());
     }
     $collection = Mage::getModel('mpassignproduct/mpassignproduct')->getCollection()->addFieldToFilter('product_id', array('in' => $products))->addFieldToFilter('created_at', array('datetime' => true, 'from' => $from, 'to' => $to))->addFieldToFilter('seller_id', array('eq' => $userId));
     if ($filter_prostatus != "") {
         $collection->addFieldToFilter('flag', array('eq' => $filter_prostatus));
     }
     $this->setCollection($collection);
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:40,代码来源:Mpassignproductlist.php

示例4: detalleOrden

 public function detalleOrden($codigo, $parametro)
 {
     $o_LTesoreria = new LTesoreria();
     $o_LPersona = new LPersona();
     $combo = $this->comboTipoDocumento('1');
     $arrayDatos = $o_LTesoreria->datosPersonales($codigo, $parametro);
     //$codigo='';
     $nombre = '';
     $fechaNacimiento = '';
     $edad = '';
     $documento = '';
     $filiacion = '';
     //print_r($arrayDatos);
     foreach ($arrayDatos as $fila) {
         //$codigo=$fila[0];
         $nombre = htmlentities($fila[4] . " " . $fila[5] . ", " . $fila[6]);
         $fechaNacimiento = $fila[7];
         $documento = $fila[0];
         $filiacion = $fila[3];
     }
     //date_default_timezone_set('Europe/London');
     $datetime = date_create($fechaNacimiento);
     $fechaNacimiento = date_format($datetime, 'm/d/Y');
     //echo date_format($datetime, DATE_ATOM);
     //echo $fechaNacimiento->format('d-m-y');
     //print_r($arrayDatos);
     $edad = $o_LPersona->formatoEdad($fechaNacimiento);
     //creando la tabla
     $arrayFilas = $o_LTesoreria->obtenerOrdenes($codigo, $parametro);
     $arrayTipo = array("10" => "h", "0" => "c", "1" => "c", "2" => "c", "11" => "h", "3" => "c", "13" => "h", "4" => "c", "5" => "c", "6" => "c", "12" => "c", "7" => "c");
     $arraycabecera = array("10" => " ", "0" => "Nro Orden", "1" => "Fecha", "2" => "Filiación", "11" => " ", "3" => "concepto", "13" => "Nro Comp.", "4" => "Precio", "5" => "Cant.", "6" => "Total", "12" => "....", "7" => "es");
     $arrayColorEstado = array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9");
     $o_Html = new Tabla1($arraycabecera, 15, $arrayFilas, 'tablaOrden', 'filax', 'filay', 'filaSeleccionada', 'onClick', '', 5, $arrayTipo, 7, $arrayColorEstado);
     require_once "../../cvista/tesoreria/detalleOrden.php";
 }
开发者ID:gianpascal,项目名称:yachay,代码行数:35,代码来源:ActionTesoreria.php

示例5: check_due_date

 public function check_due_date($date)
 {
     echo $date;
     $query = $this->db->query('SELECT * FROM rent_details')->result_array();
     //exit();
     foreach ($query as $key) {
         $due_date = $key['rent_due_date'];
         $rent = $key['rent'];
         $id = $key['id'];
         $rent_balance = $key['rent_balance'];
         $new_rent_balance = $rent_balance + $rent;
         $new_date = date_create($due_date);
         date_add($new_date, date_interval_create_from_date_string("30 days"));
         $new_rent_due_date = date_format($new_date, "Y-m-d");
         echo $new_rent_due_date;
         $date1 = date_create($date);
         $date2 = date_create($due_date);
         $diff = date_diff($date1, $date2);
         $dif = $diff->format("%a");
         if ($dif == 0) {
             if ($new_rent_balance <= 0) {
                 $this->db->query("UPDATE rent_details SET rent_due = '0' WHERE id ='" . $id . "'");
                 # code...
             } else {
                 $this->db->query("UPDATE rent_details SET rent_due = '" . $new_rent_balance . "' WHERE id ='" . $id . "'");
             }
             $this->db->query("UPDATE rent_details SET rent_balance = '" . $new_rent_balance . "' WHERE id ='" . $id . "'");
             $this->db->query("UPDATE rent_details SET rent_due_date = '" . $new_rent_due_date . "' WHERE id ='" . $id . "'");
         } else {
             //$this->db->query('UPDATE rent_details SET rent_due = '0'');
         }
     }
 }
开发者ID:FaithMaina,项目名称:Rentit,代码行数:33,代码来源:payments_model.php

示例6: createItemsHtml

 public function createItemsHtml($program = '', $loja = '', $name = '', $endDate = '', $description = '', $title = '', $trackingLink = '', $firstCupomLoja)
 {
     $htmlItem = '';
     $nameString = $this->revealName($program);
     //string usada nas imagens
     $nameCode = str_replace(" ", "-", $nameString);
     if ($firstCupomLoja) {
         $htmlItem .= '<h2 class="h-cupom" id="h-cupom-' . $nameString . '">Cupons ' . $program . '</h2>';
     }
     $htmlItem .= '<div class="campo-cupom">';
     $htmlItem .= '<span class="logo-cupom"><img src="/wp-content/themes/THEME/images/logo-cupom/cupom-de-desconto-logo-' . strtolower($nameCode) . '.jpg"></span>';
     $htmlItem .= '<h3 class="titulo-cupom">' . $name . '</h3>';
     $htmlItem .= '<a class="botao-cupom" data-title="' . title . '" data-heading="Aqui está seu cupom da ' . $nameString . '" data-subheading="' . $program . '" data-description="' . $description . '" href="' . $trackingLink . '" target="_blank"><img src="/wp-content/uploads/2015/12/botao-ver-cupom.jpg"></a>';
     if (!empty($endDate)) {
         $endDate = explode('T', $endDate)[0];
         $date = date_create($endDate);
         $endDate = date_format($date, "d/m/Y");
         $htmlItem .= '<p class="prazo-cupom">Válido até ' . $endDate . '</p>';
     }
     if (!empty($description)) {
         $htmlItem .= '<p class="info-cupom">Mais informações</p>';
         $htmlItem .= '<div class="more-information more-information-hide"><span>Mais informações</span><br/>' . $description . '</div>';
     }
     $htmlItem .= '</div>';
     $html .= $htmlItem;
     return $html;
 }
开发者ID:Danty2012,项目名称:parser-xml-zanox,代码行数:27,代码来源:classXml.php

示例7: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $dados = $request->all();
     $date = date_create($dados["data"]);
     $dados["data"] = date_format($date, "Y-m-d H:i");
     return \DB::connection('mysql')->table('feira')->where('id', $id)->update(['tipo' => $dados['tipo'], 'tema' => $dados['tema'], 'local' => $dados['local'], 'data' => $dados['data'], 'status' => $dados['status'], 'observacao' => $dados['observacao']]);
 }
开发者ID:silvacarvalho,项目名称:Treinamento,代码行数:14,代码来源:FeiraController.php

示例8: formatarDataHora

 /**
  * Formatar data e hora
  *
  * @param string $data_hora string contendo uma representação de data ou hora
  * @param string $formato   string contendo o formtado da data e/ou hora desejado. O farmato deve ser aceito pela
  *                          função date();
  *
  * @return bool|mixed|string
  */
 public static function formatarDataHora($data_hora, $formato)
 {
     # Se $formato estiver em branco retornar a data sem nenhum alteração
     if (empty($formato)) {
         return $data_hora;
     }
     // Fim if
     /*
      * Essas strings não serão aceitas, por se tratarem de datas e / ou horas inválidas
      */
     $nao_aceito = ['0000-00-00', '0000-00-00 00:00:00'];
     if (!empty($data_hora) && !in_array($data_hora, $nao_aceito)) {
         # Se a string de data não foi válida para a conversão retorná-la com uma mensagem de erro
         if (!strtotime($data_hora)) {
             return "{$data_hora} - Data informada inválida";
         }
         // Fim if
         /*
          * A função strtotime() não aceita a string da data no formato brasileiro com a '/' barra separando dia, mês e ano.
          * Portanto, caso a data seja informada dessa forma substituir a '/' barra pelo '-' hifém
          */
         if (strpos($data_hora, '/') > -1) {
             $data_hora = str_replace('/', '-', $data_hora);
         }
         // Fim if
         return date_format(date_create($data_hora), $formato);
     }
     // Fim if
 }
开发者ID:dlepera,项目名称:framework-dl,代码行数:38,代码来源:funcoes.classe.php

示例9: editAction

 public function editAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id');
     if ($id !== NULL) {
         $form = new Application_Form_Goal();
         $goalMapper = new Application_Model_GoalMapper();
         $auth = Zend_Auth::getInstance();
         $identity = $auth->getIdentity();
         $goal = new Application_Model_Goal();
         $goalMapper->find($id, $goal);
         $data = array('goal' => $goal->getGoal(), 'notes' => $goal->getNotes(), 'goal_date' => date_format(new DateTime($goal->getGoalDate()), 'Y-m-d'), 'done' => $goal->getDone());
         $form->populate($data);
         if ($request->isPost()) {
             if ($form->isValid($request->getPost())) {
                 $goalMapper = new Application_Model_GoalMapper();
                 $goal = new Application_Model_Goal($form->getValues());
                 $auth = Zend_Auth::getInstance();
                 $identity = $auth->getIdentity();
                 $goal->setId($id);
                 $goal->setUserId($identity->id);
                 $goalMapper->save($goal);
                 $goalNamespace = new Zend_Session_Namespace('goal');
                 $data = array('id' => $goal->getId(), 'goal' => $goal->getGoal(), 'notes' => $goal->getNotes(), 'goal_date' => $goal->getGoalDate(), 'done' => $goal->getDone(), 'user_id' => $goal->getUserId());
                 $goalNamespace->data = $data;
                 $this->_redirect('/goal/view/');
             }
         }
         $this->view->form = $form;
     } else {
         $this->_redirect('/dashboard');
     }
 }
开发者ID:jingjangjung,项目名称:WinsAndWants,代码行数:33,代码来源:GoalController.php

示例10: init_import

 public static function init_import($args = false)
 {
     $options = get_option('fpi_option');
     $fb = self::init();
     try {
         // Returns a `Facebook\FacebookResponse` object
         $response = $fb->get('/' . $options['fpi_page_id'] . '/feed?fields=link,full_picture,story,message,created_time,actions', $options['fpi_access_token']);
         // {"fields":"link,full_picture,story,message,created_time,actions"},
     } catch (Facebook\Exceptions\FacebookResponseException $e) {
         echo 'Graph returned an error: ' . $e->getMessage();
         exit;
     } catch (Facebook\Exceptions\FacebookSDKException $e) {
         echo 'Facebook SDK returned an error: ' . $e->getMessage();
         exit;
     }
     $graphEdge = $response->getGraphEdge();
     $list = array();
     foreach ($graphEdge as $graphNode) {
         $item = $graphNode->asArray();
         $elem = array('id' => $item['id'], 'story' => isset($item['story']) ? $item['story'] : false, 'message' => $item['message'], 'created_time' => $item['created_time'], 'created_time' => date_format($item['created_time'], 'd/m/Y'), 'permalink' => $item['actions'][0]['link'], 'full_picture' => isset($item['full_picture']) ? $item['full_picture'] : false, 'direct_url' => $item['actions'][0]['link'], 'post_date' => date_format($item['created_time'], 'Y-m-d H:i:s'));
         array_push($list, $elem);
     }
     $new_import = new FPI_Import($list);
     if ($new_import->get_status() == 200 && (isset($args['display_notices']) && $args['display_notices'] == 1)) {
         echo '<div class="notice notice-success is-dismissible"><p>Success! <a href="' . admin_url('edit.php?post_type=facebookposts') . '">See your Facebook posts here</a></p></div>';
     }
 }
开发者ID:teledirigido,项目名称:WP-Facebook-Page-Importer,代码行数:27,代码来源:controller.facebook-sdk.php

示例11: monthIntegerToString

 /**
  * @param integer $monthInteger
  * @param string $format
  * @return bool|string
  */
 public static function monthIntegerToString($monthInteger, $format = 'F')
 {
     if (is_string($monthInteger) && in_array(strtolower($monthInteger), self::$months)) {
         return $monthInteger;
     }
     return date_format(date_create("1/{$monthInteger}/2000"), $format);
 }
开发者ID:svenhartmann,项目名称:cicbase,代码行数:12,代码来源:Date.php

示例12: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $loggedInUserId = $session->get('user/id');
     $issueId = $request->request->get('id');
     $timeSpentPost = trim(str_replace(" ", '', $request->request->get('time_spent')));
     $dateStartedString = $request->request->get('date_started');
     $remainingTime = $request->request->get('remaining');
     $comment = $request->request->get('comment');
     $dateStarted = \DateTime::createFromFormat('d-m-Y H:i', $dateStartedString);
     $dateStartedString = date_format($dateStarted, 'Y-m-d H:i');
     if (is_numeric($timeSpentPost)) {
         $timeSpentPost = $timeSpentPost . $session->get('yongo/settings/time_tracking_default_unit');
     }
     if ($timeSpentPost) {
         $currentDate = Util::getServerCurrentDateTime();
         $issueQueryParameters = array('issue_id' => $issueId);
         $issue = $this->getRepository(Issue::class)->getByParameters($issueQueryParameters, $loggedInUserId);
         $this->getRepository(WorkLog::class)->addLog($issueId, $loggedInUserId, $timeSpentPost, $dateStartedString, $comment, $currentDate);
         $remainingTime = $this->getRepository(WorkLog::class)->adjustRemainingEstimate($issue, $timeSpentPost, $remainingTime, $session->get('yongo/settings/time_tracking_hours_per_day'), $session->get('yongo/settings/time_tracking_days_per_week'), $loggedInUserId);
         $fieldChanges = array(array('time_spent', null, $timeSpentPost), array('remaining_estimate', $issue['remaining_estimate'], $remainingTime));
         $this->getRepository(Issue::class)->updateHistory($issue['id'], $loggedInUserId, $fieldChanges, $currentDate);
         // update the date_updated field
         $this->getRepository(Issue::class)->updateById($issueId, array('date_updated' => $currentDate), $currentDate);
         $project = $this->getRepository(YongoProject::class)->getById($issue['issue_project_id']);
         $issueEventData = array('user_id' => $loggedInUserId, 'comment' => $comment, 'date_started' => $dateStartedString, 'time_spent' => $timeSpentPost);
         $issueEvent = new IssueEvent($issue, $project, IssueEvent::STATUS_UPDATE, $issueEventData);
         UbirimiContainer::get()['dispatcher']->dispatch(YongoEvents::YONGO_ISSUE_WORK_LOGGED, $issueEvent);
     }
     if (null == $remainingTime || '' == $remainingTime) {
         $remainingTime = -1;
     }
     return new Response($remainingTime);
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:34,代码来源:LogController.php

示例13: umur

function umur($tgl_lahir)
{
    $thn_lahir = date_format(date_create($tgl_lahir), 'Y');
    $thn_skrg = date('Y');
    $umur = $thn_skrg - $thn_lahir;
    return $umur;
}
开发者ID:ibnoe,项目名称:rsudapp,代码行数:7,代码来源:indo_helper.php

示例14: adata_edit

 public function adata_edit($id)
 {
     $data = $this->request->data;
     $date = date_create_from_format("m\\/d\\/Y", $this->data['start_date']);
     $data['start_date'] = date_format($date, 'Y-m-d H:i:s');
     $date = date_create_from_format("m\\/d\\/Y", $this->data['end_date']);
     $data['end_date'] = date_format($date, 'Y-m-d H:i:s');
     $coursemodulemap = $this->CourseLessonMap->find("first", array('conditions' => array('CourseLessonMap.lesson_id =' => $id, 'CourseLessonMap.course_id =' => $data['courseid'])));
     $old_data = $this->Lesson->findById($id);
     if ($old_data['Lesson']['published'] == 0 && $data['published'] == 1) {
         $data['published_date'] = date('Y-m-d H:i:s');
         $coursemodulemap['CourseLessonMap']['published_date'] = $data['published_date'];
     } else {
         if ($old_data['Lesson']['published'] == 1 && $data['published'] == 0) {
             $data['published_date'] = "0000-00-00 00:00:00";
             $coursemodulemap['CourseLessonMap']['published_date'] = $data['published_date'];
         }
     }
     $coursemodulemap['CourseLessonMap']['published'] = $data['published'];
     $coursemodulemap['CourseLessonMap']['lesson_type'] = $old_data['Lesson']['type'];
     $this->CourseLessonMap->save($coursemodulemap);
     $this->Lesson->id = $id;
     $courseid = $this->Lesson->save($data);
     $this->redirect("/admin/lesson/" . $data['courseid']);
 }
开发者ID:kirupalaks,项目名称:mytest,代码行数:25,代码来源:LessonController.php

示例15: updateValue

 /**
  * Update the date of the date column. The specific time of the DateTime object will be ignored.
  *
  * @api
  *
  * @param \DateTime $dateTime The new date
  *
  * @since 0.1.0
  */
 public function updateValue($dateTime)
 {
     $url = sprintf("%s/%d/columns/%s/date.json", self::apiEndpoint(), $this->board_id, $this->column_id);
     $postParams = array("pulse_id" => $this->pulse_id, "date_str" => date_format($dateTime, "Y-m-d"));
     self::sendPut($url, $postParams);
     $this->column_value = $dateTime;
 }
开发者ID:allejo,项目名称:PhpPulse,代码行数:16,代码来源:PulseColumnDateValue.php


注:本文中的date_format函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。