Convert to date format dd/mm/yyyy

前端 未结 6 932
感动是毒
感动是毒 2020-12-01 06:29

I have the following date: 2010-04-19 18:31:27. I would like to convert this date to the dd/mm/yyyy format.

6条回答
  •  一向
    一向 (楼主)
    2020-12-01 07:07

    If your date is in the format of a string use the explode function

        array explode ( string $delimiter , string $string [, int $limit ] )
    //In the case of your code
    
    $length = strrpos($oldDate," ");
    $newDate = explode( "-" , substr($oldDate,$length));
    $output = $newDate[2]."/".$newDate[1]."/".$newDate[0];
    

    Hope the above works now

提交回复
热议问题