[英]Change Date format using Carbon
I am using Laravel framework and for date conversion using Carbon package 我正在使用Laravel框架并使用Carbon包进行日期转换
I am unable convert date format to mysql format.I have following code 我无法将日期格式转换为mysql格式。我有以下代码
$request->event_start_date
will have 25/08/2017
$request->event_start_date
将于$request->event_start_date
25/08/2017
print_r(carbon::parse($request->event_start_date));
when $request->event_start_date
is 03/08/2017
then it will print as 当
$request->event_start_date
是03/08/2017
,然后将打印为
Carbon\Carbon Object( [date] => 2017-03-08 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC)
But if date is 25/08/2017
then it will throw erorr as 但是如果日期是2017年8月
25/08/2017
日,那么它会引起更多的恐惧
"G:\\XAMPP\\htdocs\\myproject\\vendor\\nesbot\\carbon\\src\\Carbon\\Carbon.php" line : 291 message : "DateTime::__construct(): Failed to parse time string (25/08/2017) at position 0 (2): Unexpected character"
“G:\\ XAMPP \\ htdocs \\ myproject \\ vendor \\ nesbot \\ carbon \\ src \\ Carbon \\ Carbon.php”行:291消息:“DateTime :: __ construct():无法解析时间字符串(25/08/2017)at位置0(2):意外字符“
need to convert 25/08/2017
to Mysql date format.I have tried a lot to fix this .finaly posted here so that i get some help from you 需要转换
25/08/2017
到Mysql日期格式。我已经尝试了很多来解决这个问题。最后发布在这里,以便我从你那里得到一些帮助
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.