change the date format in laravel view page

前端 未结 11 2136
-上瘾入骨i
-上瘾入骨i 2020-12-02 06:23

I want to change the date format which is fetched from database. now I got 2016-10-01{{$user->from_date}} .I want to change the format \'d-m-y\' in laravel

11条回答
  •  無奈伤痛
    2020-12-02 06:52

    Method One:

    Using the strtotime() to time is the best format to change the date to the given format.

    strtotime() - Parse about any English textual datetime description into a Unix timestamp

    The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.

    Example:

    
    

    Output:

    2007-02-26
    

    Method Two:

    date_format() - Return a new DateTime object, and then format the date:

    
    

    Output:

     2013/03/15 00:00:00 
    

提交回复
热议问题