2017-07-19 47 views
0

即時通訊在laravel很新,現在,我正在編輯一個編輯表單,每當我想要更改它時,出生日期總是會回到「1-1-1970」的時間。無法編輯laravel中的日期表格

我的代碼有什麼問題?

<div class="form-group"> 
    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="date_of_bday"> 
     Date Of Birthday 
     <span class="required">*</span> 
    </label> 
    <div class="col-md-6 col-sm-6 col-xs-12"> 
     <input id="single_cal1" type="text" class="form-control has-feedback-left @if($errors->has('date_of_bday')) parsley-error @endif" 
          name="date_of_bday" placeholder="Date Of Birthday" aria-describedby="inputSuccess2Status" value="{{ date('m/d/Y', strtotime($member->dob)) }}" required> 
     <span class="fa fa-calendar form-control-feedback left" aria-hidden="true"></span> 
    </div> 
</div> 
+1

你檢查數據庫?它正在存儲的日期? –

+0

檢查數據庫的日期格式以及您嘗試存儲日期的格式。 – dexterb

+0

我如何檢查日期格式?或者我可以找到代碼來重新格式化它?對不起,如果這是一個愚蠢的問題,這裏的新手..嘿嘿 – vrivaldy

回答

0

使用Carbon解析日期和相應的格式化

<div class="form-group"> 
    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="date_of_bday"> 
     Date Of Birthday 
     <span class="required">*</span> 
    </label> 
    <div class="col-md-6 col-sm-6 col-xs-12"> 
     <input id="single_cal1" type="text" class="form-control has-feedback-left 
     @if($errors->has('date_of_bday')) parsley-error @endif" 
     name="date_of_bday" 
     placeholder="Date Of Birthday" 
     aria-describedby="inputSuccess2Status" 
     value="{{ Carbon\Carbon::parse($member->dob)->format('m/d/Y') }}" 
     required> 
     <span class="fa fa-calendar form-control-feedback left" aria-hidden="true"></span> 
    </div> 
</div>