Laravel 将基督教历法转换为夏姆西历法

Laravel 将基督教历法转换为夏姆西历法,laravel,composer-php,Laravel,Composer Php,我想使用此软件包将日期和时间转换为波斯日历: 此包转换为shamsi,但for循环不起作用 运行以下代码: return new Verta($show[$i]['created_at']); 在此代码中,将日期和时间显示为日期时间格式 但是这个代码不起作用: $ishow['message'][$i]['time'] =new Verta($show[$i]['created_at']); 在这段代码中显示的是基督教日期时间格式 我的主要问题是使用chiristian格式的for循环显示

我想使用此软件包将日期和时间转换为波斯日历:

此包转换为shamsi,但for循环不起作用

运行以下代码:

return new Verta($show[$i]['created_at']);
在此代码中,将日期和时间显示为日期时间格式

但是这个代码不起作用:

$ishow['message'][$i]['time'] =new Verta($show[$i]['created_at']);
在这段代码中显示的是基督教日期时间格式

我的主要问题是使用chiristian格式的for循环显示“created_at”


如何使用它?

我有兴趣尝试这个库,所以我测试了它,它与
新Verta($item->created_at)
Verta::instance($item->created_at)
一起使用。我的代码如下:

foreach ($items as $item){
 $shamsi[] = Verta::instance($item->created_at);
}
dd($shamsi);
您的
$ishow
似乎没有从旧表单更新。让我们试试下面的代码:

$ishow = [];
foreach ($show as $item){
 $ishow['message'][]['time'] = Verta::instance($item->created_at);
}
return $ishow;
或使用for循环:

$ishow = [];
for ($i = 0; $i < count($show); $i++) { 
  $ishow['message'][$i]['time'] =new Verta($show[$i]['created_at']); 
}
return $ishow;
$ishow=[];
对于($i=0;$i
错误消息是什么?show以christian格式创建于。我可以知道您的完整代码如何获取变量
$show
$show=comment::where([['type',1]])->选择('id','sender','receiver','text','created_at')->get();如何使用
$ishow
?在此代码格式中,数据是chiristian的。我想用波斯语格式显示日期和时间我试过了,它返回波斯语,我认为你的代码有问题,所以请显示你的完整代码和它的返回