本文整理汇总了PHP中DateTimeUtil::convertTimestampToDisplayFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeUtil::convertTimestampToDisplayFormat方法的具体用法?PHP DateTimeUtil::convertTimestampToDisplayFormat怎么用?PHP DateTimeUtil::convertTimestampToDisplayFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeUtil
的用法示例。
在下文中一共展示了DateTimeUtil::convertTimestampToDisplayFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateMeetingFromForm
/**
* @depends testCreateAndGetMeetingById
*/
public function testUpdateMeetingFromForm()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = User::getByUsername('billy');
$meetings = Meeting::getByName('MyMeeting');
$meeting = $meetings[0];
$this->assertEquals($meeting->name, 'MyMeeting');
$timeStamp = time();
$newStamp = DateTimeUtil::convertTimestampToDbFormatDateTime($timeStamp);
$postData = array('owner' => array('id' => $user->id), 'name' => 'New Name', 'startDateTime' => DateTimeUtil::convertTimestampToDisplayFormat($timeStamp, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true));
$sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($meeting, $postData);
$meeting->setAttributes($sanitizedPostData);
$saved = $meeting->save();
$this->assertTrue($saved);
$id = $meeting->id;
unset($meeting);
$meeting = Meeting::getById($id);
$this->assertEquals('New Name', $meeting->name);
$this->assertEquals($sanitizedPostData['startDateTime'], $meeting->startDateTime);
//create new meeting from scratch where the startDateTime and endDateTime attributes are not populated.
//It should let you save.
$meeting = new Meeting();
$postData = array('owner' => array('id' => $user->id), 'name' => 'Lamazing', 'startDateTime' => DateTimeUtil::convertTimestampToDisplayFormat($timeStamp, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true));
$sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($meeting, $postData);
$meeting->setAttributes($sanitizedPostData);
$saved = $meeting->save();
$this->assertTrue($saved);
$id = $meeting->id;
unset($meeting);
$meeting = Meeting::getById($id);
$this->assertEquals('Lamazing', $meeting->name);
$this->assertEquals($sanitizedPostData['startDateTime'], $meeting->startDateTime);
$this->assertEquals(null, $meeting->endDateTime);
}
示例2: actionGetMeetingEndDateTimeBasedOnStartDateTime
public function actionGetMeetingEndDateTimeBasedOnStartDateTime($startDateTime = null)
{
Yii::app()->getClientScript()->setToAjaxMode();
if ($startDateTime == null) {
return null;
}
$timestamp = CDateTimeParser::parse($startDateTime, DateTimeUtil::getLocaleDateTimeFormatForInput());
if ($timestamp == null) {
return null;
}
$endTimeStamp = $timestamp + 15 * 60;
$endDateTime = DateTimeUtil::convertTimestampToDisplayFormat((int) $endTimeStamp, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true);
echo CJSON::encode(array('endDateTime' => $endDateTime));
Yii::app()->end(0, false);
}