当前位置: 首页>>代码示例>>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;未经允许,请勿转载。