I have the following query but it's returning an empty array (I know for a fact that this query should return one record)
$created_at = date("Y-m");
$content = ContentModel::where('userId', $id->_id)
->where('created_at', 'like', "%{$created_at}%")
->orderBy('fav', 'DESC')
->get();
If I remove the ->where('created_at', 'like', "%{$created_at}%")
it returns everything fine but I want content that was of this year and month but the query doesn't work when I put that in.
The date in the database is ISODate format
"created_at" : ISODate("2015-02-03T16:29:26.965Z")
I'm taking a guess it's because of the ISODate format. How do I get the result I need?
Thanks