carton识别不了2021.01.07这类的时间格式
大佬们,我在定时任务中设置carbon::now->diffindays($date);时 因为数据库有java那边直接导入的数据 会有像2021.01.07这种时间格式 然后carbon识别不了 报 Could not parse ‘2021.01.07’: DateTime::__construct(): Failed to parse time string (2021.01.07) at position 5 (0): Double time specification 错误 这个如何解决?
只能转换一遍了。 Carbon::parse(str_replace('.','-','2020.1.7')); 先把 '.' 转换成 '-'