• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CakeTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: afterFind

 public function afterFind($results, $primary = false)
 {
     Configure::write('debug', 2);
     App::uses("CakeTime", "Utility");
     $gc = new CakeTime();
     parent::afterFind($results, $primary);
     if (isset($results[0]['Order']['timestamp'])) {
         foreach ($results as $key => $val) {
             $results[$key]['Order']['created'] = $gc->timeAgoInWords($results[$key]['Order']['timestamp']);
         }
     }
     return $results;
 }
开发者ID:ashutoshdev,项目名称:pickmeals-web,代码行数:13,代码来源:Order.php


示例2: index

 /**
  * Relatórios
  */
 public function index()
 {
     // Carrega o model Schedules
     $this->loadModel('Schedule');
     // Se a requisição é do tipo post
     if ($this->request->is('post')) {
         $this->layout = "print";
         $this->set('orientation', 'landscape');
         // Opções de busca
         $options = array('conditions' => array('Schedule.created >' => CakeTime::format($this->request->data['Reports']['start'], "%Y-%m-%d %H:%M"), 'Schedule.created <' => CakeTime::format($this->request->data['Reports']['end'], "%Y-%m-%d %H:%M")), 'order' => array('Patient.name' => 'asc', 'Schedule.created' => 'asc'));
         //debuga options
         $this->set(compact('options'));
         // Resultados de busca
         $schedules = $this->Schedule->find('all', $options);
         // Compacta para view
         $this->set(compact('schedules'));
         $this->render('results');
         $this->generated_pdf("relatorio_consolidado_");
     } else {
         $this->set('orientation', 'landscape');
         //$this->layout = "print";
         // Faz uma busca e compacta todas as requisições cadastradas
         $schedules = $this->Schedule->find('all', array('order' => array('Patient.name' => 'asc', 'Schedule.created' => 'asc')));
         $this->set(compact('schedules'));
         //$this->render('results');
         //$this->generated_pdf("relatorio_teste");
     }
 }
开发者ID:patrickacioli,项目名称:exames,代码行数:31,代码来源:ReportsController.php


示例3: getByComponente

 public function getByComponente()
 {
     $this->layout = "ajax";
     $incidencias = $this->Incidencia->Componente->find("first", array("contain" => array("Incidencia" => array("conditions" => array("Incidencia.estado" => 1, "Incidencia.fecha between ? and ?" => array(CakeTime::format($this->request->data["Componente"]["fechaInicio"], "%Y-%m-%d"), CakeTime::format($this->request->data["Componente"]["fechaFin"], "%Y-%m-%d")))), "Incidencia.Cruce"), "conditions" => array("Componente.idComponente" => $this->request->data["Componente"]["idComponente"])));
     $incidencias = $incidencias["Incidencia"];
     $this->set("incidencias", $incidencias);
 }
开发者ID:Rabp9,项目名称:registro-incidencias,代码行数:7,代码来源:ReportesController.php


示例4: testTime

 /**
  * HtmlExtHelperTest::testTime()
  *
  * @return void
  */
 public function testTime()
 {
     $time = time();
     $is = $this->Html->time($time);
     $time = CakeTime::i18nFormat($time, '%Y-%m-%d %T');
     $expected = '<time datetime="' . $time . '">' . $time . '</time>';
     $this->assertEquals($expected, $is);
 }
开发者ID:ByMyHandsOnly,项目名称:BMHO_Web,代码行数:13,代码来源:HtmlExtHelperTest.php


示例5: afterFind

 public function afterFind($results, $primary = false)
 {
     App::uses('CakeTime', 'Utility');
     foreach ($results as &$result) {
         if (isset($result[$this->alias]['modified'])) {
             $result[$this->alias]['niceday'] = CakeTime::niceShort($result[$this->alias]['modified']);
         }
     }
     return $results;
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:10,代码来源:DocumentVersion.php


示例6: timeAgo

 public function timeAgo($timestamp)
 {
     $timeAgo = CakeTime::timeAgoInWords($timestamp, array('accuracy' => array('hour' => 'hour'), 'end' => '1 year'));
     $timeAgo = trim(str_replace('ago', '', str_replace('second', 'seconde', str_replace('hour', 'heure', str_replace('day', 'jour', str_replace('week', 'semaine', str_replace('month', 'mois', $timeAgo)))))));
     if ($timeAgo == 'just now') {
         $timeAgo = 'il y a quelques secondes';
     } else {
         $timeAgo = 'il y a ' . $timeAgo;
     }
     return $timeAgo;
 }
开发者ID:julienasp,项目名称:Pilule,代码行数:11,代码来源:AppHelper.php


示例7: getHolidayInYear

 /**
  * getHolidayInYear
  * 指定された年の祝日日付を返す
  * getHolidayのラッパー関数 YYYYに年始まりの日付と最終日付を付与してgetHolidayを呼び出す
  *
  * @param string $year 指定年(西暦)‘YYYY’ 形式の文字列
  * @return array期間内のholidayテーブルのデータ配列が返る
  */
 public function getHolidayInYear($year = null)
 {
     // $yearがnullの場合は現在年
     if ($year === null) {
         // 未設定時は現在年
         $year = CakeTime::format((new NetCommonsTime())->getNowDatetime(), '%Y');
     }
     $from = $year . '-01-01';
     $to = $year . '-12-31';
     $holidays = $this->getHoliday($from, $to);
     return $holidays;
 }
开发者ID:s-nakajima,项目名称:Holidays,代码行数:20,代码来源:Holiday.php


示例8: getTimezoneOffset

 /**
  * Used for GMT offset for a timezone
  * @param string $timezone: timezone name
  * @return string GMT offset for the given timezone
  * @author Laxmi Saini
  */
 function getTimezoneOffset($timezone = null)
 {
     if ($timezone != '') {
         $dateTimeObj = new DateTime();
         $date_time_zone = CakeTime::timezone($timezone);
         $dateTimeObj->setTimeZone($date_time_zone);
         $offset = $dateTimeObj->getOffset();
         return $this->formatGmtOffset($offset);
     } else {
         return "";
     }
 }
开发者ID:yogesha3,项目名称:yogesh-test,代码行数:18,代码来源:TimezoneComponent.php


示例9: ageFromBirthdate

 /**
  * Calculates the current age of someone born on $birthdate.
  * Source: stackoverflow.com/questions/3776682/php-calculate-age
  * @param sing $birthdate The birthdate.
  * @return integer The calculated age.
  * @access public
  * @static
  */
 public static function ageFromBirthdate($birthdate)
 {
     // convert to format: YYYY-MM-DD
     $clean_birthdate = date('Y-m-d', CakeTime::fromString($birthdate));
     if (CakeTime::isFuture($clean_birthdate)) {
         throw new OutOfRangeException("Birthdate is in the future: {$clean_birthdate}", BedrockTime::EXCEPTION_CODE_FUTURE_BIRTHDATE);
     }
     //explode the date to get month, day and year
     $parts = explode('-', $clean_birthdate);
     //get age from date or birthdate
     $age = intval(date('md', date('U', mktime(0, 0, 0, $parts[1], $parts[2], $parts[0]))) > date('md') ? date('Y') - $parts[0] - 1 : date('Y') - $parts[0]);
     return $age;
 }
开发者ID:quentinhill,项目名称:bedrock,代码行数:21,代码来源:BedrockTime.php


示例10: isTokenValid

 public function isTokenValid($token)
 {
     $tokenAuth = $this->find('first', array('conditions' => array('Token.token' => $token)));
     if ($tokenAuth) {
         $expiryDate = $tokenAuth['Token']['token_expiry_date'];
         if (CakeTime::gmt($expiryDate) < CakeTime::gmt()) {
             return false;
         } else {
             return $tokenAuth['Token'];
         }
     } else {
         return false;
     }
 }
开发者ID:schnauss,项目名称:angular-cakephp-auth,代码行数:14,代码来源:Token.php


示例11: index

 /**
  * index method
  *
  * @return void
  */
 public function index()
 {
     $targetYear = null;
     // 指定年取り出し
     if (isset($this->params['named']['targetYear'])) {
         $targetYear = $this->params['named']['targetYear'];
     } else {
         $targetYear = CakeTime::format((new NetCommonsTime())->getNowDatetime(), '%Y');
     }
     // 祝日設定リスト取り出し
     $holidays = $this->Holiday->getHolidayInYear($targetYear);
     // View変数設定
     $this->set('holidays', $holidays);
     $this->set('targetYear', $targetYear);
 }
开发者ID:s-nakajima,项目名称:Holidays,代码行数:20,代码来源:HolidaysController.php


示例12: admin_login

 /**
  * Auth Login page
  */
 public function admin_login()
 {
     if (Configure::read('Backend.Auth.enabled') !== true) {
         if (isset($this->Auth)) {
             $this->redirect($this->Auth->loginAction);
         } else {
             $this->redirect('/');
         }
     }
     $this->layout = "Backend.auth";
     $defaultRedirect = Configure::read('Backend.Dashboard.url') ? Configure::read('Backend.Dashboard.url') : array('plugin' => 'backend', 'controller' => 'backend', 'action' => 'dashboard');
     $redirect = false;
     if ($this->request->is('post')) {
         if (!$this->Auth->login()) {
             //Event Backend.Auth.onLoginFail
             $eventData = array('user' => $this->request->data['BackendUser'], 'ip' => $this->request->clientIp());
             // $event = new CakeEvent('Backend.Controller.Auth.onLoginFail', $this, $eventData);
             // $this->getEventManager()->dispatch($event);
             $this->Session->setFlash(__d('backend', 'Login failed'), 'error', array(), 'auth');
         } else {
             //Event Backend.Auth.onLogin
             $event = new CakeEvent('Backend.Controller.Auth.onLogin', $this, $this->Auth->user());
             //$this->getEventManager()->dispatch($event);
             $this->Session->setFlash(__d('backend', 'Login successful'), 'success');
             if ($this->Auth->user('lastlogin')) {
                 $this->Session->setFlash(__d('backend', 'Last login: %s', CakeTime::timeAgoInWords($this->Auth->user('last_login'))), 'default', array(), 'auth');
             }
             //TODO should the event result return an redirect url?
             if ($event->result) {
                 $redirect = $event->result;
             } else {
                 $redirect = $this->Auth->redirect();
             }
             $redirect = Router::normalize($redirect);
             if ($redirect == '/' || !preg_match('/^\\/admin\\//', $redirect) || $redirect == '/admin/backend') {
                 $redirect = $defaultRedirect;
             }
             $this->redirect($redirect);
         }
     } elseif ($this->Auth->user()) {
         $redirect = $this->referer($defaultRedirect, true);
         $this->redirect($redirect);
     }
     $this->set(compact('redirect'));
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:48,代码来源:AuthController.php


示例13: index

 /**
  * Loop through active controllers and generate sitemap data.
  */
 public function index()
 {
     $controllers = App::objects('Controller');
     $sitemap = array();
     // Fetch sitemap data
     foreach ($controllers as $controller) {
         App::uses($controller, 'Controller');
         // Don't load AppController's, SitemapController or Controller's who can't be found
         if (strpos($controller, 'AppController') !== false || $controller === 'SitemapController' || !App::load($controller)) {
             continue;
         }
         $instance = new $controller($this->request, $this->response);
         $instance->constructClasses();
         if (method_exists($instance, '_generateSitemap')) {
             if ($data = $instance->_generateSitemap()) {
                 $sitemap = array_merge($sitemap, $data);
             }
         }
     }
     // Cleanup sitemap
     if ($sitemap) {
         foreach ($sitemap as &$item) {
             if (is_array($item['loc'])) {
                 if (!isset($item['loc']['plugin'])) {
                     $item['loc']['plugin'] = false;
                 }
                 $item['loc'] = h(Router::url($item['loc'], true));
             }
             if (array_key_exists('lastmod', $item)) {
                 if (!$item['lastmod']) {
                     unset($item['lastmod']);
                 } else {
                     $item['lastmod'] = CakeTime::format(DateTime::W3C, $item['lastmod']);
                 }
             }
         }
     }
     // Disable direct linking
     if (empty($this->request->params['ext'])) {
         throw new NotFoundException();
     }
     // Render view and don't use specific view engines
     $this->RequestHandler->respondAs($this->request->params['ext']);
     $this->set('sitemap', $sitemap);
 }
开发者ID:alescx,项目名称:cakephp-utils,代码行数:48,代码来源:SitemapController.php


示例14: follow_expedient

 /**
  * index method
  *
  * @return void
  */
 public function follow_expedient($idE = null)
 {
     App::uses('CakeTime', 'Utility');
     $confirmas = $this->Confirma->Expediente->find('all', array('conditions' => array('Expediente.user_id' => $idE)));
     if (isset($confirmas[0]['Expediente']['previsao_chegada']) && !empty($confirmas[0]['Expediente']['previsao_chegada'])) {
         if (CakeTime::isToday($confirmas[0]['Expediente']['previsao_chegada'])) {
             /* greet user with a happy birthday message
                  Enviar um email alertando sobre a data quase vencida.
                */
             $vence_hoje = 'Chega Hoje';
             if (isset($vence_hoje) && empty($vence_hoje)) {
                 $vence_hoje = '';
             }
             $this->set('vence_hoje', $vence_hoje);
         }
     }
     $this->set(compact('confirmas', 'idE'));
 }
开发者ID:Goncalves007,项目名称:Projecto-EI,代码行数:23,代码来源:ConfirmasController.php


示例15: register

 public function register()
 {
     if (empty($this->request->data)) {
         $queryString = '?' . http_build_query($this->request->query);
         $this->set(compact('queryString'));
     } else {
         $this->request->data['Token']['password'] = Security::hash($this->request->data['Token']['password'], 'md5');
         $this->request->data['Token']['token'] = Security::hash($this->request->data['Token']['email'], 'md5');
         $this->request->data['Token']['type'] = 'application';
         $this->request->data['Token']['token_expiry_date'] = CakeTime::format('+365 days', '%Y-%m-%d');
         $this->Token->save($this->request->data);
         $bearerTokenReceivingUrl = urldecode($this->request->query['client_bearer_token_receiving_url']);
         unset($this->request->query['client_bearer_token_receiving_url']);
         $this->request->query['bearer_token'] = $this->request->data['Token']['token'];
         $this->request->query['login_type'] = 'application';
         return $this->redirect($bearerTokenReceivingUrl . '?' . http_build_query($this->request->query));
     }
 }
开发者ID:schnauss,项目名称:angular-cakephp-auth,代码行数:18,代码来源:TokensController.php


示例16: formatDateFields

 public function formatDateFields($results, $dates, $format = "%d/%m/%Y")
 {
     if (!empty($dates)) {
         $setResult = function ($val, $key) use(&$results, $format) {
             $innerKey = explode("/", $key);
             $results[$innerKey[0]][$innerKey[1]][$innerKey[2]] = CakeTime::format($val, $format);
         };
         $extracted = Set::extract($results, "/{$this->alias}");
         $dateExtracted = Set::classicExtract($extracted, '{\\w+}.{\\w+}.{' . implode("|", $dates) . '}');
         $applied = Set::apply("/", $dateExtracted, function ($val) {
             return count(Set::filter($val)) > 0 ? $val : null;
         });
         if ($applied) {
             $flatten = Set::flatten($applied, "/");
             array_walk($flatten, $setResult);
         }
     }
     return $results;
 }
开发者ID:AmmonMa,项目名称:cake_ERP,代码行数:19,代码来源:AppModel.php


示例17: updateInfo

 public function updateInfo($attrs)
 {
     $this->create();
     if (!empty($attrs['book_id'])) {
         $this->set('book_id', $attrs['book_id']);
         $book = $this->Book->find('first', array('conditions' => array('Book.id' => $attrs['book_id'])));
     }
     if (!empty($attrs['user_id'])) {
         $this->set('user_id', $attrs['user_id']);
     }
     if ($attrs['event'] == 'bet_start') {
         $content = '[Bet Now!] ' . $book['Book']['title'] . ' | Bet start time:' . CakeTime::format($book['Book']['bet_start'], '%Y/%m/%d %H:%M') . ' , The bet has started!';
     } elseif ($attrs['event'] == 'bet_result') {
         $content = '[Result Announcement!] ' . $book['Book']['title'] . ' | Announcement time:' . CakeTime::format($book['Book']['modified'], '%Y/%m/%d %H:%M') . ' ,  The results have been announced!';
     }
     $this->set('content', $content);
     $this->set('event', $attrs['event']);
     $this->save();
 }
开发者ID:shivram2609,项目名称:bbm,代码行数:19,代码来源:Update.php


示例18: admin_genericos

 function admin_genericos()
 {
     // $keypass = $this->Auth->user('empresa_id')*2313231323132313;
     // $login = array(
     //     'acesso' => 1,
     //     'empresa_id' => $this->Auth->user('empresa_id'),
     //     'post_keypass' => 'BL'.$keypass.'AC'
     // );
     $this->autoRender = false;
     $model = 'Conteudo';
     $this->set('model', $model);
     $keypass = $this->params->query['keypass'];
     $empresa_id = substr($keypass, 2, -2);
     $empresa_id = $empresa_id / 2313231323132313;
     $sql = "SELECT c.*, e.empresa_id FROM tb_conteudo as c JOIN tb_conteudo_empresas as e ON c.id = e.conteudo_id WHERE e.empresa_id = {$empresa_id}";
     $all = $this->{$model}->query($sql);
     $json_rdy["conteudos"] = array();
     foreach ($all as $content) {
         $created = CakeTime::format('%d | %e de %B', $content['c']['created']);
         $json_rdy["conteudos"] = array("id" => $content['c']['id'], "categoria_id" => $content['c']['categoria_id'], "titulo" => $content['c']['titulo'], "texto" => $content['c']['texto'], "created" => $created);
     }
     echo "<pre>";
     print_r($json_rdy);
 }
开发者ID:indirasam,项目名称:aquitemmata,代码行数:24,代码来源:JsonsController.php


示例19: checkPastDate

 /**
  * checkPastDate
  * Custom Validation Rule: Ensures a selected date is either the
  * present day or in the past.
  *
  * @param array $check Contains the value passed from the view to be validated
  * @return bool True if in the past or today, False otherwise
  */
 public function checkPastDate($check)
 {
     $value = array_values($check);
     return CakeTime::fromString($value[0]) <= CakeTime::fromString(date(Configure::read('databaseDateFormat')));
 }
开发者ID:cepedag14,项目名称:phkondo,代码行数:13,代码来源:Maintenance.php


示例20: start

 public function start($round_id = null, $user_id = null, $operation = null)
 {
     $this->Round = $this->AnnotatedDocument->Round;
     $this->User = $this->Round->User;
     $this->UsersRound = $this->Round->UsersRound;
     $this->Project = $this->Round->Project;
     $this->Document = $this->Project->Document;
     $this->Type = $this->Round->Type;
     $this->Relation = $this->Project->Relation;
     $this->DocumentsProject = $this->Project->DocumentsProject;
     $this->Annotation = $this->Round->Annotation;
     $this->AnnotationsInterRelation = $this->Annotation->AnnotationsInterRelation;
     $this->Job = $this->User->Job;
     $find = false;
     $isReviewAutomaticAnnotation = false;
     switch ($operation) {
         case "find":
             $find = true;
             break;
         case "lastAutomatic":
             $isReviewAutomaticAnnotation = true;
             break;
     }
     $this->Round->id = $round_id;
     if (!$this->Round->exists()) {
         throw new NotFoundException(__('Invalid round'));
     }
     //
     $group_id = $this->Session->read('group_id');
     if ($group_id > 1) {
         $redirect = array('controller' => 'rounds', 'action' => 'index');
         $user_id = $this->Session->read('user_id');
     } else {
         $redirect = array('controller' => 'rounds', 'action' => 'view', $round_id);
     }
     if ($isReviewAutomaticAnnotation) {
         $documents = $this->Job->find('first', array('recursive' => -1, 'fields' => array("comments"), 'conditions' => array('Job.comments IS NOT NULL', 'Job.exception IS NULL', 'Job.user_id' => $user_id, 'Job.round_id' => $round_id, 'program' => 'Automatic_Dictionary_Annotation'), 'order' => array('Job.modified DESC')));
         if (!empty($documents)) {
             $documents = json_decode($documents['Job']['comments'], true);
             if (json_last_error() == JSON_ERROR_NONE) {
                 $documents = array_keys($documents["documentsWithAnnotations"]);
                 if (empty($documents)) {
                     $this->Session->setFlash(__('There are no recommendations for you [JSON empty]'));
                     $this->redirect($redirect);
                 }
             } else {
                 $this->Session->setFlash(__('There are no recommendations for you [JSON parser error]'));
                 $this->redirect($redirect);
             }
         } else {
             $this->Session->setFlash(__('There are no recommendations for you'));
             $this->redirect($redirect);
         }
     }
     $this->User->id = $user_id;
     if (!$this->User->exists()) {
         throw new NotFoundException(__('Invalid User'));
     }
     //
     $userRound = $this->UsersRound->find('first', array('recursive' => -1, 'fields' => 'id', 'conditions' => array('user_id' => $user_id, 'round_id' => $round_id)));
     $users_round_id = $userRound['UsersRound']['id'];
     $this->UsersRound->id = $userRound['UsersRound']['id'];
     if ($this->UsersRound->field('state') != 0) {
         $this->Session->setFlash(__('There are one process working in this documents'));
         $this->redirect($redirect);
     }
     $isMultiDocument = Configure::read('documentsPerPage') > 1;
     if ($find && $group_id == 1) {
         $isMultiDocument = false;
     } else {
         $find = false;
     }
     $round_id = $this->UsersRound->field('round_id');
     //        $round = Cache::read('round-id-' . $round_id, 'short');
     //        if (!$round) {
     //buscamos el round para saber la fecha de finalizacion
     $round = $this->Round->find('first', array('recursive' => -1, 'conditions' => array('Round.id' => $round_id)));
     //            Cache::write('round-id-' . $round_id, $round, 'short');
     //        }
     if (empty($round)) {
         throw new NotFoundException(__('Empty round data'));
     }
     App::uses('CakeTime', 'Utility');
     $isEnd = CakeTime::isPast($round['Round']['ends_in_date']);
     if ($group_id > 1) {
         if (isset($round['Round']['start_document'])) {
             $offset = $round['Round']['start_document'] - 1;
             if ($offset < 0) {
                 $offset = 0;
             }
             $limit = $round['Round']['end_document'];
         } else {
             $offset = 0;
             $limit = 0;
         }
     } else {
         $offset = 0;
         $limit = 0;
         $isEnd = true;
     }
//.........这里部分代码省略.........
开发者ID:sing-group,项目名称:Markyt,代码行数:101,代码来源:AnnotatedDocumentsController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Calculator类代码示例发布时间:2022-05-20
下一篇:
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap