本文整理汇总了PHP中kartik\datecontrol\DateControl::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateControl::getTimestamp方法的具体用法?PHP DateControl::getTimestamp怎么用?PHP DateControl::getTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kartik\datecontrol\DateControl
的用法示例。
在下文中一共展示了DateControl::getTimestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionConvert
/**
* Convert display date for saving to model
*
* @return string JSON encoded HTML output
*/
public function actionConvert()
{
$output = '';
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$post = Yii::$app->request->post();
if (isset($post['displayDate'])) {
$type = empty($post['type']) ? Module::FORMAT_DATE : $post['type'];
$saveFormat = ArrayHelper::getValue($post, 'saveFormat');
$dispFormat = ArrayHelper::getValue($post, 'dispFormat');
$dispTimezone = ArrayHelper::getValue($post, 'dispTimezone');
$saveTimezone = ArrayHelper::getValue($post, 'saveTimezone');
$settings = ArrayHelper::getValue($post, 'settings', []);
$dispDate = ArrayHelper::getValue($post, 'displayDate');
$date = DateControl::getTimestamp($type, $dispDate, $dispFormat, $dispTimezone, $settings);
if (empty($date) || !$date) {
$value = '';
} elseif ($saveTimezone != null) {
$value = $date->setTimezone(new DateTimeZone($saveTimezone))->format($saveFormat);
} else {
$value = $date->format($saveFormat);
}
return ['status' => 'success', 'output' => $value];
} else {
return ['status' => 'error', 'output' => 'No display date found'];
}
}
示例2: actionConvert
/**
* Convert display date for saving to model
*
* @return string JSON encoded HTML output
*/
public function actionConvert()
{
$output = '';
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$post = Yii::$app->request->post();
if (isset($post['displayDate'])) {
$saveFormat = ArrayHelper::getValue($post, 'saveFormat');
$dispFormat = ArrayHelper::getValue($post, 'dispFormat');
$dispTimezone = ArrayHelper::getValue($post, 'dispTimezone');
$saveTimezone = ArrayHelper::getValue($post, 'saveTimezone');
$settings = ArrayHelper::getValue($post, 'settings', []);
// Russian dates ends with \r. - i dont know why
if (StringHelper::endsWith($dispFormat, '.')) {
$dispFormat = substr($dispFormat, 0, strlen($dispFormat) - 4);
$post['displayDate'] = substr($post['displayDate'], 0, strlen($post['displayDate']) - 4);
}
if (ArrayHelper::getValue($post, 'type') != DateControl::FORMAT_DATETIME) {
$dispTimezone = null;
$saveTimezone = null;
}
$date = DateControl::getTimestamp($post['displayDate'], $dispFormat, $dispTimezone, $settings);
if (empty($date) || !$date) {
$value = '';
} elseif ($saveTimezone != null) {
$value = $date->setTimezone(new DateTimeZone($saveTimezone))->format($saveFormat);
} else {
$value = $date->format($saveFormat);
}
return ['status' => 'success', 'output' => $value];
} else {
return ['status' => 'error', 'output' => 'No display date found'];
}
}
示例3: actionConvert
/**
* Convert display date for saving to model.
*
* @return string JSON encoded HTML output
*/
public function actionConvert()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$post = Yii::$app->request->post();
if (!isset($post['displayDate'])) {
return ['status' => 'error', 'output' => 'No display date found'];
}
$saveFormat = $dispFormat = $dispTimezone = $saveTimezone = $displayDate = '';
$settings = [];
extract($post);
$date = DateControl::getTimestamp($displayDate, $dispFormat, $dispTimezone, $settings);
if (empty($date) || !$date) {
$value = '';
} elseif ($saveTimezone != null) {
$value = $date->setTimezone(new DateTimeZone($saveTimezone))->format($saveFormat);
} else {
$value = $date->format($saveFormat);
}
return ['status' => 'success', 'output' => $value];
}