I have a datetime string of format 'Y-m-d H:i:s', and datetime value as '2018-01-30 07:11:21'.
$carbon_obj = Carbon::createFromFormat('Y-m-d H:i:s' , '2018-01-30 07:11:21','America/Chicago');
How do it get the Unix timestamp from this carbon object?
just add timestamp
at the back of your code.
$carbon_obj = Carbon::createFromFormat('Y-m-d H:i:s' , '2018-01-30 07:11:21','America/Chicago')->timestamp;
or
$carbon_obj = Carbon::createFromFormat('Y-m-d H:i:s' , '2018-01-30 07:11:21','America/Chicago');
$carbon_obj->timestamp;
If you have data missing
error. missing it is the data your passed it not a complete date format.
Try this.
$timestp = Carbon::createFromFormat('Y-m-d H:i:s', Carbon::parse($trans['transaction_datetime']) ,Setting::get('timezone'))->timestamp;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With