本文整理汇总了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);
示例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'));
}