0

Im using Morilog\Jalali package

I have datepicker input that The output like this: 1400/08/01

I want to convert this to gregorian and insert that to database

My database field is datetime My Controller Store method is this:

Panelfile::create([

'title' => $request->title,

'color' => $request->color,

'expiration' => \morilog\Jalali\CalendarUtils::createCarbonFromFormat('Y/m/d', $request->expiration),

]);

But i have this error: Undifine index:year

How solve that?

Sina
  • 37
  • 5

1 Answers1

0

You should use toGregorian to convert Jalali to Gregorian. Like this:

\Morilog\Jalali\CalendarUtils::toGregorian(1395, 2, 18); // [2016, 5, 7]

Notice that the output is an array: so, if you want to store the string in DB, you can implode the output with -.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83