简体   繁体   中英

Date format in laravel controller

I have order time and order date I want to combine them together and make it in the correct format like this

2020-06-18T21:51:10+08:00 what is the meaning of T? and the api im dealing with wont work without this format

order_time: 12:21 pm

order_date: 2020-06-19

I tried with this but i need it to be combined in datetime format

$asapTime  = date("h:i a", strtotime($order_time));
$printDate  = date("Y-m-d ", strtotime($order_date));

Hope this helps:

$time  = date("h:i a", strtotime($order_time));
$date  = date("Y-m-d ", strtotime($order_date));
$timestamp1 = date('Y-m-dTH:i:sO', strtotime("$date $time"));
$timestamp2 = date('Y-m-d\TH:i:sO', strtotime("$date $time")); // If you need T instead of abbreviations 

Output:

$timestamp1 = "2020-06-19CEST07:58:00+0200"
$timestamp2 = "2020-06-19T08:06:00+0200"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM