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

arshver's avatar

Convert date persian to english

Only converts a year to English Do not turn day and month

public function store(Request $request){
 
        request()->validate([
            'matn' => 'required',
            'datex' => 'required'
       ]);
        $arabic = ['٩', '٨', '٧', '٦', '٥', '٤', '٣', '٢', '١','٠'];
        $num = range(0, 9);
        $convert = str_replace($persian, $num, $request->datex);
        list($year, $month, $day) = explode('-', $convert);


       $user=Post::create([
            'menu_id'=> $request->name,
            'user_id'=>auth()->user()->id,
            'body'=>$request->matn,
            'Expiration_date' =>Verta::getGregorian($year, $month, $day)
       ]);
0 likes
1 reply

Please or to participate in this conversation.