當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateControl::getTimestamp方法代碼示例

本文整理匯總了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'];
     }
 }
開發者ID:luobenyu,項目名稱:blog-1,代碼行數:31,代碼來源:ParseController.php

示例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'];
     }
 }
開發者ID:alexsuter,項目名稱:yii2-datecontrol,代碼行數:38,代碼來源:ParseController.php

示例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];
 }
開發者ID:kartik-v,項目名稱:yii2-datecontrol,代碼行數:25,代碼來源:ParseController.php


注:本文中的kartik\datecontrol\DateControl::getTimestamp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。