我希望从created_at列中显示类似于01 June这样的内容。我尝试过像这样的一些东西,我知道这很愚蠢。
<span class="day">{{date('m', $new->created_at)}}</span>
{{ $object->created_at->format('d M') }}
对于日期和月份
{{ $object->created_at->format('M') }}
一个月的时间
{{ $object->created_at->format('d') }}
仅供当日使用
$object
指的是从控制器传递到模板的变量。
$timestamp = strtotime($new->created_at);
//Uppercase letters gives day, month in language(Jan, Third, etc)
$day = date('D', $timestamp);
$month = date('M', $timestamp);
//lowercase letters gives day, month in numbers(1, 3, etc)
$day = date('d', $timestamp);
$month = date('m', $timestamp);
//use a combination of both, eg: 01 June
$final_Date = date('d', $timestamp) .' '. date('M', $timestamp);
<span class="day">{{\Carbon\Carbon::parse($new->created_at)->format('d M')}}</span>
$timestamp = strtotime($new->created_at);
$day = date('D', $timestamp);
$month = date('M', $timestamp);
Carbon::parse($data->created_at)->format('l');
这将以星期名称的形式回应您。
$id = 1 ;
$users=data::find($id);//Fetching record using primary key from data named table
$month=$users->created_at->format('m'); //getting month
$day=$users->created_at->format('d');//getting day
dd("Month : ".$month."\nDay : ".$day);//Printing Month & day
Carbon\Carbon::parse($quotation[0]->created_at)->format('d M')
。该语句将解析$quotation[0]
的created_at
时间戳并按照指定格式输出日期和月份。 - Maraboc