Format a date string in PHP

后端 未结 4 1454
渐次进展
渐次进展 2021-01-12 10:47

If I have a string which represents a date, like \"2011/07/01\" (which is 1st July 2011) , how would I output that in more readable forms, like:

1 July 201         


        
4条回答
  •  北海茫月
    2021-01-12 11:25

    As for the second one:

    $time1 = time();
    $time2 = $time1 + 345600; // 4 days
    if( date("j",$time1) != date("j",$time2) && date("FY",$time1) == date("FY",$time2) ){
       echo date("j",$time1)." - ".date("j F Y",$time2);
    }
    

    Can be seen in action here

    Just make up more conditions

提交回复
热议问题