[英]Date format in laravel controller
我有訂單時間和訂單日期我想將它們組合在一起並以正確的格式制作,如下所示
2020-06-18T21:51:10+08:00
T 是什么意思? 如果沒有這種格式,我處理的 api 將無法工作
訂購時間:下午 12:21
訂購日期:2020-06-19
我試過這個,但我需要它以datetime
時間格式組合
$asapTime = date("h:i a", strtotime($order_time));
$printDate = date("Y-m-d ", strtotime($order_date));
希望這可以幫助:
$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"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.