morilog / jalali

This Package helps developers to easily work with Jalali (Shamsi or Iranian) dates in php appliations, based on Jalali (Shamsi) DateTime class.
MIT License
860 stars 110 forks source link

set jDate for timestamp field type in laravel #46

Closed fahamjv closed 5 years ago

fahamjv commented 6 years ago

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '1397-06-23 11:45:30' for column 'updated_at' at row 1 (SQL: update products set updated_at = 1397-06-23 11:45:30 where id = 26)

and i don't wanna change the timestamp type to datetime in my table

morilog commented 5 years ago

You must store datatime as Gregorian calendar type, use jalali calendar only for displaying in views or reports. for example:

$product->created_at = jDateTime::createCarbonFromFormat('Y-m-d H:i:s', '1397-06-23 11:45:30');
$product->save();