Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Carbon\Carbon;
- $oldDate = '2023-7-15';
- $todayDate = date('Y-m-d');//Todday's date 30-07-23
- $futureDate = '2023-08-3';
- $parseOldDate = Carbon::parse($oldDate);
- $parseTodayDate = Carbon::parse($todayDate);
- $parseFutureDate = Carbon::parse($futureDate);
- if ($parseOldDate->isPast())
- {
- return "this $oldDate is in the past "; // check if date is in the past
- } //ouputs : this 2023-07-15 in the past
- if($parseFutureDate->isFuture()) // check if date is in the future
- {
- return "this $futureDate is in the future "; // outputs: this 2023-08-3 in the future
- }
- // if($parseTodayDate->isToday()){ // check if date is in the past
- // return "this $todayDate is in the today ";
- // }
- /* if( date('w') !=0 && date('w') !=6) // check if day is weekend (Saturday or Sunday)
- {
- return "Today is not weekend ";
- } */
- /* if($parseTodayDate->isWeekend()){ //check if day is weekend (Saturday or Sunday)
- return "Today is weekend ";
- } */
- /* if($parseTodayDate->isWeekday()){ //check if day is weekend (Saturday or Sunday)
- return "Today is weekday ";
- } */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement