【问题标题】:Codeigniter Date formatCodeigniter 日期格式
【发布时间】:2010-03-11 18:48:07
【问题描述】:

我在 codeignitor config.php 中有以下日期格式

$config['log_date_format'] = 'd/m/Y';

Ans wen 我在文本输入字段中输入“30/04/2010”并尝试保存,得到他以下错误

ERROR: date/time field value out of range: "30/04/2010" HINT: Perhaps you need a different "datestyle" setting

对应的查询如下

UPDATE "assignments" SET "id" = '2', "name" = 'Stadium complex', "date_started" = '30/04/2010', "date_completed" = NULL, "assigned_id" = '9', "customer_id" = '4', "description" = NULL WHERE "id" = '2'

我该如何解决他的问题?保存前需要格式化日期吗?

【问题讨论】:

    标签: php date codeigniter format


    【解决方案1】:

    config.php 中的“log_date_format”设置是 CodeIgniter 日志文件中条目的日期格式。它与您遇到的错误没有任何关系。

    错误来自您的 PostgreSQL 数据库服务器。您尝试在查询中使用的日期格式不是 PostgreSQL 所期望的。您可以通过运行以下命令了解 PostgreSQL 期望的日期格式:

    SHOW DATESTYLE;
    

    你可以通过执行命令告诉 PostgresSQL 你打算使用什么日期格式

    SET DATESTYLE TO '<SOME_DATESTYLE>';
    

    More information can be found in the PostgreSQL manual.

    【讨论】:

      猜你喜欢
      • 2012-09-11
      • 2012-06-19
      • 1970-01-01
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      相关资源
      最近更新 更多