我是新來php和laravel和MariaDB 10.1.xx.使用laravel 5.2。Laravel 5如何在select子句中使用Carbon轉換日期相關列?
測試表具有索引和日期(yyyymmdd)列。
我想將日期格式從yyyymmdd轉換爲YYYYmm,而不使用select子句中的原始查詢。
我試了一下如下:
$test = DB::table('test')
->select('idx',Carbon::parse('date')->format('Ym'));
,並得到了如下錯誤:
DateTime::__construct(): Failed to parse time string (date) at position 0 (n): The timezone could not be found in the database.
請讓我有什麼想法,解決使用碳而不是原始查詢這個問題。