The easiest solution is using createFromFormat and then calling timestamp
e.g. (assuming it is day/month/year)
Carbon\Carbon::createFromFormat('d/m/Y H', $data[0])->timestamp
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am importing CSV data and the date/time field is formatted kinda weird and come in as:
06/01/2018 01
06/01/2018 02
06/01/2018 03
...
I would like to save this to a date field in a DB in Unix(Epoch)Time format.
Each ends up being $data[0] on the CSV import.
I tried something like:
$date = date_create($data [0]);
$reading->time = (int)date_format($date, 'U');
But it does not really work.
The last two digits are the hour. So this is hourly. I have CARBON installed if that is any help.
Thank you in advanced!
The easiest solution is using createFromFormat and then calling timestamp
e.g. (assuming it is day/month/year)
Carbon\Carbon::createFromFormat('d/m/Y H', $data[0])->timestamp
Please or to participate in this conversation.