Codeigniter日期格式 [英] Codeigniter Date format

查看:111
本文介绍了Codeigniter日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码信息config.php中有以下日期格式

I have se the below date format in the codeignitor config.php

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

在文本输入字段中输入'30 / 04/2010'并尝试保存,遇到以下错误

Ans wen I enter '30/04/2010' in the text input field and tried to save, got he following error

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'

我如何解决他?我需要在保存前格式化日期吗?

How can I solve his? Do I need to format the date before save?

推荐答案

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

The 'log_date_format' setting in config.php is the date format for entries in your CodeIgniter log file. It does not have anything to do with the error you are getting.

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

The error is coming from your PostgreSQL database server. The date format you are trying to use in your query is not one that PostgreSQL is expecting. You can find out what date format PostgreSQL is expecting by running the command :

SHOW DATESTYLE;

您可以通过执行命令告诉PostgresSQL要使用的日期格式

You can tell PostgresSQL what date format you intend to use by executing the command

SET DATESTYLE TO '<SOME_DATESTYLE>';

有关详细信息,请参阅PostgreSQL手册。

这篇关于Codeigniter日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆