2016-03-23 33 views
-1

不兼容的引導日期時間我有這樣的MYSQL在我的表中的列:現在插入特定的語言環境格式的MySQL

| TANGGAL_PERSETUJUAN | datetime     | YES |  | NULL |    | 

,在HTML中,我用js從bootstrap-datetimepicker。我使用印尼文格式的地區id。我的代碼看起來像這樣:

<div class="form-group"> 
    label class="control-label col-md-3">Estimasi</label> 
    <div class="col-md-9"> 
     <div class="form-inline"> 
      <div class="form-group"> 
       <input name="perkiraan_selesai" class="form-control datetime" type="text"> 
       <span class="help-block"></span> 
      </div> 
     </div> 
    </div> 
</div> 

$('.datetime').datetimepicker({ 
     locale: 'id' 
}); 

現在麻煩來了。 DATETIME在MySQL?我用PHP這樣的: PHP

$dataMaster = array(
     'ID_KARYAWAN' => $this->input->post('nama'), 
     'TANGGAL_PERSETUJUAN' => $this->input->post('tanggal_persetujuan'), 
     'TANGGAL_TERIMA' => $this->input->post('tanggal_terima'), 
     'PERKIRAAN_SELESAI' => $this->input->post('perkiraan_selesai'), 
     'TANGGAL_SELESAI' => $this->input->post('tanggal_selesai'), 
     'PELAKSANA' => $this->input->post('pelaksana'), 
     'KELUHAN' => $this->input->post('keluhan'), 
     'CATATAN' => $this->input->post('catatan') 
    ); 


    print_r($this->input->post()); 

輸出:

Array 
(
[id] => 
[nama] => 5 
[tanggal_persetujuan] => 23/03/2016 00.00 
[tanggal_terima] => 23/03/2016 00.00 
[perkiraan_selesai] => 23/03/2016 00.00 
[tanggal_selesai] => 23/03/2016 00.00 
[pelaksana] => Awan 
[tipe] => Array 
    (
     [0] => 2 
    ) 

[item] => Array 
    (
     [0] => 3 
    ) 

[keluhan] => Test 
[catatan] => Saja 
) 
+0

如果您遇到錯誤,請將此添加到您的問題中。看起來你正在使用數據類型錯誤 - 在你的數據庫中:它應該是數據類型'TIMESTAMP'在你的情況 – KDOT

+0

沒有錯誤。我應該使用日期時間因爲時間不活。我剛剛得到了0000-00-00 00:00:00 –

+0

那你確定你插入了正確的數據嗎? 'var_dump'你試圖插入並確保在插入它們之前它們是正確的格式,那麼你應該沒有問題做你正在做什麼或兼容性問題。您只需將日期插入數據庫 – KDOT

回答

0

你將有問題,例如MySQL把日期格式爲年月日在此情況下,2016年3月23日 我有不使用引導日期,但使用Jquery UI日期選擇器工作。 當檢索日期回到輸出到瀏覽器時,您確實需要格式化輸出。 當把這個日期分成年份和日期並分配單個變量時,可以這樣做。 關於Jase

相關問題