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


PHP Date::add方法代碼示例

本文整理匯總了PHP中Jenssegers\Date\Date::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP Date::add方法的具體用法?PHP Date::add怎麽用?PHP Date::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Jenssegers\Date\Date的用法示例。


在下文中一共展示了Date::add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getUsers

 public function getUsers(Request $request)
 {
     Date::setLocale('th');
     $records = [];
     $records["data"] = [];
     $filters = [];
     if ($request->input('customActionType') && $request->input('customActionType') == "group_action" && $request->input('customActionName') == "delete") {
         if (count($request->input('id')) > 0) {
             $deleted = DB::table('TBL_PRIVILEGE')->whereIn('USER_PRIVILEGE_ID', $request->input('id'))->delete();
             if ($deleted) {
                 $records["customActionStatus"] = "OK";
                 $records["customActionMessage"] = "ลบข้อมูลผู้ใช้เรียบร้อยแล้ว";
             } else {
                 $records["customActionStatus"] = "Errors";
                 $records["customActionMessage"] = "ไม่สามารถลบข้อมูลผู้ใช้ได้";
             }
         }
     }
     $query = DB::table('TBL_USER')->select('TBL_USER.EMP_ID', 'TBL_EMPLOYEE_INFO.FULL_NAME', 'TBL_USER.USERNAME', 'TBL_USER.USER_STATUS_ID', 'TBL_USER_STATUS.STATUS_DESC', 'TBL_USER.USER_PRIVILEGE_ID', 'TBL_PRIVILEGE.USER_PRIVILEGE_DESC', 'TBL_USER.EMAIL', 'TBL_USER.PHONE', 'TBL_USER.CREATE_DATE', 'TBL_USER.LAST_MODIFY_DATE')->leftJoin('TBL_EMPLOYEE_INFO', 'TBL_USER.EMP_ID', '=', 'TBL_EMPLOYEE_INFO.EMP_ID')->leftJoin('TBL_PRIVILEGE', 'TBL_PRIVILEGE.USER_PRIVILEGE_ID', '=', 'TBL_USER.USER_PRIVILEGE_ID')->leftJoin('TBL_USER_STATUS', 'TBL_USER_STATUS.USER_STATUS_ID', '=', 'TBL_USER.USER_STATUS_ID');
     if (!empty($request->input('user_id'))) {
         $filters = ['TBL_USER.EMP_ID', $request->input('user_id')];
     }
     if (!empty($request->input('full_name'))) {
         $filters = ['TBL_EMPLOYEE_INFO.FULL_NAME', 'like', $request->input('full_name') . '%'];
     }
     if ($request->input('user_group') != "") {
         $filters = ['TBL_USER.USER_PRIVILEGE_ID', $request->input('user_group')];
     }
     if (!empty($request->input('email'))) {
         $filters = ['TBL_USER.EMAIL', 'like', $request->input('email') . '%'];
     }
     if (!empty($request->input('phone'))) {
         $filters = ['TBL_USER.PHONE', 'like', $request->input('phone') . '%'];
     }
     if ($filters) {
         $query->where([$filters]);
     }
     $total = $query->count();
     $limit = intval($request->input('length'));
     $limit = $limit < 0 ? $limit : $limit;
     $iDisplayStart = intval($request->input('start'));
     $sEcho = intval($request->input('draw'));
     $order = $request->input('order');
     $orderColumns = [1 => 'TBL_USER.EMP_ID', 2 => 'TBL_EMPLOYEE_INFO.FULL_NAME', 3 => 'TBL_USER.USERNAME', 4 => 'TBL_USER_STATUS.STATUS_DESC', 5 => 'TBL_PRIVILEGE.USER_PRIVILEGE_DESC', 6 => 'TBL_USER.EMAIL', 7 => 'TBL_USER.PHONE', 8 => 'TBL_USER.CREATE_DATE', 9 => 'TBL_USER.LAST_MODIFY_DATE'];
     if ($order) {
         $query->orderBy($orderColumns[$order[0]['column']], $order[0]['dir']);
     } else {
         $query->orderBy('TBL_USER.EMP_ID', 'desc');
     }
     $users = $query->skip($iDisplayStart)->take($limit)->get();
     if ($users) {
         foreach ($users as $user) {
             $create_date_str = '';
             if ($user->CREATE_DATE) {
                 $create_date = new Date($user->CREATE_DATE);
                 $create_date_str = $create_date->add('543 years')->format('d M Y H:i:s');
             }
             $last_modify_date_str = '';
             if ($user->LAST_MODIFY_DATE) {
                 $last_modify_date = new Date($user->LAST_MODIFY_DATE);
                 $last_modify_date_str = $last_modify_date->add('543 years')->format('d M Y H:i:s');
             }
             $records["data"][] = [sprintf('<input type="checkbox" name="id[]" value="%1$s">', $user->EMP_ID), $user->EMP_ID, $user->FULL_NAME, $user->USERNAME, $user->STATUS_DESC, $user->USER_PRIVILEGE_DESC, $user->EMAIL, $user->PHONE, $create_date_str, $last_modify_date_str, sprintf('<a href="%1$s" target="_blank"  class="btn btn-sm btn-outline grey-salsa"><i class="fa fa-pencil"></i>&nbsp;แก้ไข</a><a data-toggle="modal" href="#deleteUserGroup" data-group_name="%2$s" data-group_id="%3$s" class="btn btn-sm btn-outline red-thunderbird row-user-group-%4$s"><i class="fa fa-remove"></i>&nbsp;ลบ</a>', action('UserGroupController@getEditUserGroup', $user->EMP_ID), $user->EMP_ID, $user->EMP_ID, $user->EMP_ID)];
         }
     }
     $records["draw"] = $sEcho;
     $records["recordsTotal"] = $total;
     $records["recordsFiltered"] = $total;
     return response()->json($records);
 }
開發者ID:FreelanceDArkman,項目名稱:MEA,代碼行數:70,代碼來源:UserManageFundController.php

示例2: Date

 function get_date_year($input)
 {
     Date::setLocale('th');
     $create_date = new Date($input);
     return $create_date->add('543 years')->format('Y');
 }
開發者ID:FreelanceDArkman,項目名稱:MEA,代碼行數:6,代碼來源:helpers.php


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