简体   繁体   English

使用Carbon将日期转换为另一种格式

[英]Using Carbon to convert a date to another format

I Have a date thats 12/1/2018 and i want to switch it to 2018/12/01 and im using carbon but im unsure on how to do this. 我有一个12/1/2018的日期,我想把它切换到2018/12/01并使用碳但我不确定如何做到这一点。

I've tried using the parse method and carbon seems to confuse me and i get random errors. 我试过使用解析方法,碳似乎让我感到困惑,我得到随机错误。

解决了它,我用过:

Carbon::parse($input)->format('Y-m-d'); // converts MM/DD/YYYY to YYYY/MM/DD

你应该试试这个:

Carbon::parse('12/1/2018')->format('Y/m/d');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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