What column type is the reading?
Extract date value of timestamp as a comparison
I am passing a collection of tag movements from Controller to View. The collection items each have a timestamp (ReadingTimestampUTC) and a scan direction () which will either be in or out. Each record represents someone swiping in or out of the office card swipe system.
In my view in a particular place I want to display the actual time when a person scanned out today. Currently I have the following in my View which doesn't work unless a swipe out is done exactly at midnight:
{{$tagmovements->where('ReadingTimestampUTC',\Carbon\Carbon::today())->where('ScanDirection','OUT')->pluck('ReadingTimestampUTC')}}
The problem is the 'ReadingTimestampUTC' is a datetime value and I just want it to be a date value with the time stripped out so it matches the \Carbon\Carbon::today() which is a date only. (time is 0).
Is there any way I can just get the date component of the timestamp in this code? I tried this:
{{$tagmovements->where(date("Y-m-d",'ReadingTimestampUTC'),\Carbon\Carbon::today())->where('ScanDirection','OUT')->pluck('ReadingTimestampUTC')}}
but I get an error of "date() expects parameter 2 to be integer" which isn't surprising. My alternative, if I can't get this working, it to add another field with just the date value to do the comparison.
Please or to participate in this conversation.