CodeIgniter:将日期格式从yyyy-mm-dd更改为dd-mm-yyyy

时间:2017-02-28 09:38:06

标签: codeigniter date date-conversion

我想将日期格式从yyyy-mm-dd更改为dd-mm-yyyy,但我不能。

我的观点:

<div class="form-group">
<label class="control-label labelnya"><i class="fa fa-calendar-o"></i>&nbsp; Tanggal Surat : </label>
<div class="input-group date" id="datepickerDemo17">
    <div class="has-success">
        <input type="text" class="form-control inputan " name="tgl_surat" placeholder="Masukan Waktu Penetapan"/>
    </div>
    <span class="input-group-addon tomb_calender" style="padding: 5px 15px; line-height: 0;">
        <i class=" ion ion-calendar"></i>
    </span>
</div>

pictures of view

2 个答案:

答案 0 :(得分:3)

如果您使用jquery日期选择器

<script>
    $( function() {
        $( "#datepicker" ).datepicker( "option", "dateFormat", "dd-mm-yy" );
    } );
</script>

或PHP

$date = date('d-m-Y', strtotime($old_format_date) );    

答案 1 :(得分:1)

此视图

<div class="form-group">
<label class="control-label labelnya"><i class="fa fa-calendar-o"></i>&nbsp; Tanggal Surat : </label>
<div class="input-group date" id="datepickerDemo17">
    <div class="has-success">
        <input type="text" class="form-control inputan kusus" id="tgl_surat" data-format="dd-MM-yyyy" name="tgl_surat" placeholder="Masukan Waktu Penetapan"/>
    </div>
    <span class="input-group-addon tomb_calender" style="padding: 5px 15px; line-height: 0;">
        <i class=" ion ion-calendar"></i>
    </span>
</div>
</div>

这个javascript

<script type="text/javascript"> 
$(function(){
    $("#tgl_surat").datepicker({
        todayHighlight: true,
        format: "dd-mm-yyyy"
    });
})
</script>