kirobo kirobo - 1 year ago 175
PHP Question

Laravel - Carbon Convert Meridian Time to DateTime

I have this DateTime format.

2016-11-22 12:04 PM

I want to convert it to UTC datetime which can be inserted into MysQL.

Can somebody please tell how to do it with carbon?

Answer Source

Set your timezone and add this code something like this.Hope this will be helped you.

$timestamp = '2016-11-22 12:04 PM';
$date = Carbon::createFromFormat('Y-m-d H:i A', $timestamp, 'America/New_York');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download