Carbon : How to get only date without time ? Hello ,
I try to get only the date without time :
$condition->value=Carbon::parse($seg["value"])->format('d-m-Y');
but the result is : 2020-03-17T11:07:00.000Z
How to keep only the Date ? 2020-03-17
$condition->value=Carbon::parse($seg["value"])->toDateString()
@sinnbeck thanks, but same problem :
the $condition->value type is string not date (It must be string , I cant change it )
sorry i dont understand? ->toDateString() return a string as the name implies
Carbon\Carbon::now()->toDateString(); //=> "2020-03-09"
@sinnbeck yes that's true but when I check the DB table I see : 2020-03-13T11:20:00.000Z I need just 2020-03-13
If it does not work, we will need more information. LIke what is $condition and how do you use it.
Is the column of type datetime? If so that is supposed to happen
looks like an ISO8601 timestamp. You can just take the left most 10 characters?
Thanks @sinnbeck @snapey
the @sinnbeck answer is working :Carbon\Carbon::now()->toDateString(); I restarted the server and it works (no idea what was the problem)
Thats just the current timestamp. What happened to the value in your database?
@snapey the value now is like : 2020-03-03 (string type and also the table column type is string -required to be string-)
Carbon::parse($seg["value"])->format('Y-m-d');
Please sign in or create an account to participate in this conversation.