简体   繁体   中英

How to check date and time to today in laravel

I have doing a project. In my project I want to show a start button when the time and date is current date and time. Say Today is 9 th October. If a user gives serial to 10 to 12 am in 9th October, then the start button will show only 10 to 12 am of 9th october. how can I achieve this. My view is

<a class="btn btn-info" style="margin-right: 0" href="{{ URL::to('booking/reject/'.$booking->id) }}">Reject</a>
@elseif ( !empty($booking->is_accepted) && $booking->is_accepted == 1)
 <a class="btn btn-info" style="margin-right: 0">Accepted</a>

<a class="btn btn-info" style="margin-right: 0" href="http://devteam.website/esp+hadfkku+hhj2hjh2+q+web+video+calling/index.php?r=videochat/login">Start</a>
@elseif ( !empty($booking->is_accepted) && $booking->is_accepted == 2)
   <a class="btn btn-info" style="margin-right: 0">Rejected</a>
@endif

My Controler is

public function profile($username) {
        $username_exists = User::where('username', $username)->first();
        if (!empty($username_exists)) {
            if (Auth::check()) {
                $username_exists->no_of_viewer = $username_exists->no_of_viewer + 1 ;
                $username_exists->save() ;
                if (UserRole::where('user_id', Auth::user()->id)->first()->role_id == 2) {
                    $bookings = Booking::where('provider_id', Auth::user()->id)->orderBy('id', 'desc')->get();
                } elseif (UserRole::where('user_id', Auth::user()->id)->first()->role_id == 3) {
                    $bookings = Booking::where('provider_id', Auth::user()->id)->orderBy('id', 'desc')->get();
                } else {
                    $bookings = '';
                }

                $payments = Payment::where('user_id', Auth::user()->id)->orWhere('provider_id', Auth::user()->id)->get();
            }
            $data = [
                'user' => $username_exists,
                'user_detail' => UserDetail::where('user_id', $username_exists->id)->first(),
                'user_share' => UserShare::where('user_id', $username_exists->id)->first(),
                'user_work_experiences' => UserWorkExperience::where('user_id', $username_exists->id)->where('is_deleted', 0)->get(),
                'user_academic_experiences' => UserAcademicExperience::where('user_id', $username_exists->id)->where('is_deleted', 0)->get(),
                'user_meetings' => UserMeeting::where('user_id', $username_exists->id)->first(),
                'user_time' => UserTime::where('user_id', $username_exists->id)->first(),
                'bookings' => (!empty($bookings)) ? $bookings : '',
                'reviews' => Review::where('provider_id', $username_exists->id)->get(),
                'rating' => Review::where('provider_id', $username_exists->id)->avg('rating'),
                'payments' => !empty($payments)?$payments:''
            ];
            return view('frontends.profile', $data);
        } else {
            return view('errors.503');
        }
    }

Please help

$dt = new DateTime();

echo $dt->format('Ymd H:i:s');

要么:

$mytime = Carbon\Carbon::now();

echo $mytime->toDateTimeString();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM