How orderBy date when is a variable type String Hi.
I want to sort a variable of type string but it contains date format. (10/30/2018) <- String. The orderby method sorts it as a String. any solution?
why dont you change the type of the colomn to make things easier.
What sort of data structure are you working with here?
Consider parsing the date string and normalizing the format to yyyy-mm-dd which will sort in the expected manner.
You can try something like this, which get all the post of user_id 23 with any given date,
public function yourFunction(Request $request){
$data = $this->post
->where('user_id', 23)
->whereDate('date', Carbon::parse($request->date)->format('Y-m-d'))
->get();
}
Please sign in or create an account to participate in this conversation.