本文整理汇总了PHP中Cake\I18n\Time::setJsonEncodeFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP Time::setJsonEncodeFormat方法的具体用法?PHP Time::setJsonEncodeFormat怎么用?PHP Time::setJsonEncodeFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\I18n\Time
的用法示例。
在下文中一共展示了Time::setJsonEncodeFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRender
/**
* Before render callback.
*
* @param \Cake\Event\Event $event The beforeRender event.
* @return void
*/
public function beforeRender(Event $event)
{
if (!array_key_exists('_serialize', $this->viewVars) && in_array($this->response->type(), ['application/json', 'application/xml'])) {
$this->set('_serialize', true);
}
Time::setToStringFormat('dd/MM/yy, HH:MM');
Time::setJsonEncodeFormat('dd/MM/yy, HH:MM');
$this->set('renderLayoutTitle', $this->renderLayoutTitle);
$this->set('userLoggedIn', $this->Auth->user());
}
示例2: testJsonEnconde
/**
* Tests encoding a Time object as json
*
* @return void
*/
public function testJsonEnconde()
{
$time = new Time('2014-04-20 10:10:10');
$this->assertEquals('"2014-04-20T10:10:10+0000"', json_encode($time));
Time::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss');
$this->assertEquals('"2014-04-20 10:10:10"', json_encode($time));
}
示例3: getPostsWithTag
public function getPostsWithTag()
{
Time::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss');
date_default_timezone_set('America/Sao_Paulo');
if ($this->request->is('post')) {
$result = $this->Posts->find('byTagName', ['tag' => $this->request->data['data']]);
$this->paginate = ['maxLimit' => 10, 'order' => ['Posts.post_date' => 'desc']];
if ($result == null) {
echo 'algo deu errado =/';
} else {
$this->set('posts', $this->paginate($result));
$this->render('pagination-container');
}
} else {
echo 'its not post request';
}
}
示例4: dirname
<?php
/**
* Encoding : UTF-8
* Created on : 2015-12-26 22:58:51 by allen <blog.rc5j.cn> , caowenpeng1990@126.com
*/
require dirname(__FILE__) . '/function.php';
//引入全局函数文件
use Cake\Event\Event;
use Cake\Event\EventManager;
use Cake\Database\Type\TimeType;
use Cake\I18n\Time;
spl_autoload_register(function ($class) {
// echo $class;
//include_once dirname(__FILE__) . '/' . str_replace('\\', '/', $class) . 'php';
});
//TimeType::$dateTimeClass = 'Admin\I18n\DateOnly';
Time::setJsonEncodeFormat('yyyy-MM-dd HH:mm:ss');
if (PHP_SAPI === 'cli') {
// Attach bake events here.
EventManager::instance()->on('Bake.beforeRender.Controller.controller', function (Event $event) {
$view = $event->subject();
// if(strpos('Admin.', $view->viewVars['plugin'])!==FALSE){
if ($view->theme == 'Admin') {
// add the login and logout actions to the Users controller
$view->viewVars['actions'] = ['index', 'view', 'add', 'edit', 'delete', 'getDataList', 'exportExcel'];
}
// if ($view->viewVars['name'] == 'Admin') {
});
}