Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tuytoosh's avatar

save Solar date in database

I have a solar date picker and it give me a date like this format : 15/02/1394 I want to save this date in my database... I have a date field in my database. when I try to save date , it saved like this :0000-00-00 how can save this date? and: what is true? 1.save date with this format 15/02/1394 2.convert it to for example 2015-5-5

0 likes
9 replies
bobbybouwmann's avatar

If you do it like this it should work fine

public function create(Request $request)
{
    $project = new Project();
    $project->date = Carbon::parse('15/02/1394'); 

    $project->save();
}
JarekTkaczyk's avatar

Like @bobbybouwmann , but use createFromFormat('d/m/Y', $value).

parse treats such date as m/d/Y, it will throw error for 12+ first segment, and obviously will hold different date to what you expect.

jimmck's avatar

Is the year 1394?? This will cause problems using UNIX date on the database side.

tuytoosh's avatar

@jimmck the solar date format is like this 15/02/1394 and i must use this format. what is your idea about solving this problem?

tuytoosh's avatar

@bobbybouwmann , yes , I am Iranian. we work with solar date. for example today is 20/02/1394. and now it is my problem that can I save my date with this format or must convert?

bobbybouwmann's avatar

Mmh no idea on how to use those kind of dates, you might be able to find a package that can convert the current time into your specific time?

Please or to participate in this conversation.