简体   繁体   中英

How to change Laravel date format

$from_date_time = get_before_of_string(' - ', $request->date_range); //06/23/2021 12:00 AM $to_date_time = get_after_of_string(' - ', $request->date_range); //06/23/2021 12:00 AM

$from_date_time = Carbon::parse($from_date_time)->format('Ymd H:i:s'); //2021-06-24 14:30:00 this is DB format $to_date_time = Carbon::parse($to_date_time)->format('Ymd H:i:s'); //2021-06-24 14:30:00 this is DB format

$from_date_time = get_before_of_string(' - ', $request->date_range); //06/23/2021 12:00 AM $to_date_time = get_after_of_string(' - ', $request->date_range); //06/23/2021 12:00 AM

    $from_date_time = Carbon::parse($from_date_time)->format('Y-m-d H:i:s'); //2021-06-24 14:30:00 this is DB format
    $to_date_time = Carbon::parse($to_date_time)->format('Y-m-d H:i:s'); //2021-06-24 14:30:00 this is DB format

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