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


PHP Request::getDateTime方法代码示例

本文整理汇总了PHP中Xoops\Core\Request::getDateTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getDateTime方法的具体用法?PHP Request::getDateTime怎么用?PHP Request::getDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xoops\Core\Request的用法示例。


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

示例1: dirname

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
use Xoops\Core\Request;
use Xoops\Core\Locale\Time;
/**
 * @copyright 2011-2015 XOOPS Project (http://xoops.org)
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @author    trabis <lusopoemas@gmail.com>
 * @author    Richard Griffith <richard@geekwright.com>
 */
include dirname(dirname(__DIR__)) . '/mainfile.php';
$xoops = Xoops::getInstance();
$xoops->header();
$default = Time::cleanTime();
$dateOnly = Request::getDateTime('date', $default);
$dateAndTime = Request::getDateTime('date_time', $default);
// Date demo form
$form = new Xoops\Form\ThemeForm('Date and Time', 'form_localedates', '', 'post');
$date = new Xoops\Form\DateSelect('Date', 'date', $dateOnly);
$date->setDescription(\XoopsLocale::formatTimestamp($dateOnly, 'custom'));
$form->addElement($date, true);
$date_time = new Xoops\Form\DateTime('Date time', 'date_time', $dateAndTime);
$date_time->setDescription(Time::describeRelativeInterval($dateAndTime));
$form->addElement($date_time, true);
$buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
$form->addElement($buttonSubmit);
$form->display();
// Locale selection form
$localePicker = new Xoops\Form\ThemeForm('Change Locale', 'form_locale', '', 'get');
$localeSelect = new Xoops\Form\SelectLocale('Locale', 'lang', Request::getString('lang', 'en_US'));
$localePicker->addElement($localeSelect);
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:31,代码来源:locale.php

示例2: testGetDateTime

 /**
  * @covers Xoops\Core\Request::getDateTime
  */
 public function testGetDateTime()
 {
     $varname = 'datetimetest';
     \Xoops\Locale::setTimeZone(new \DateTimeZone('UTC'));
     \Xoops\Locale::setCurrent('en_US');
     $exampleDate = '12/14/2015';
     $exampleTime = '12:10 AM';
     $_REQUEST[$varname] = $exampleDate;
     $actual = Request::getDateTime($varname);
     $this->assertInstanceOf('\\DateTime', $actual);
     $this->assertEquals($exampleDate, $actual->format('m/d/Y'));
     $_REQUEST[$varname] = ['date' => $exampleDate, 'time' => $exampleTime];
     $actual = Request::getDateTime($varname);
     $this->assertInstanceOf('\\DateTime', $actual);
     $this->assertEquals($exampleDate, $actual->format('m/d/Y'));
     $this->assertEquals($exampleTime, $actual->format('h:i A'));
 }
开发者ID:ming-hai,项目名称:XoopsCore,代码行数:20,代码来源:RequestTest.php


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