I want to store a timestamp in the database with time component as 00:00:00
.
The following code:
$start_date = Carbon::createFromFormat('d-m-Y', $date_interval["start_date"]);
$end_date = Carbon::createFromFormat('d-m-Y', $date_interval["end_date"]);
adds the current time to the date, when I provide a date only without time specification.
I need this because I need to retrieve the internal integer from the database afterwards which should be the start of the day.
What is the best way to store this 'start of day'?
For safety just let Carbon decide the end or the start of the day using ->endOfDay()
or ->startOfDay()
. Choose what suits you more.
Carbon::createFromFormat('d-m-Y', $date_interval["start_date"])->endOfDay();
Carbon::createFromFormat('d-m-Y', $date_interval["start_date"])->startOfDay();