0

Does anyone know of an existing CodeIgniter (CI 2.0) Helper (or Library) that I can use to help with date and time formatting for views? Maybe something that uses the PHP5 DateTime class?

Most of our data is in the typical GMT/UTC format within a MySQL database. We now need to set a User's timezone (part of our admin/auth/acl) and then display everything by their timezone setting. I assume this would be easy to do with a CI helper or perhaps a library. Any ideas?

4

4 回答 4

2

PHP's DateTime Classes and functions are fully available in CodeIgniter. No Library/Helper required...

于 2011-08-15T18:48:05.840 回答
1

That kind of things is so specific that you'll have to make it yourself. See creating CI libraries and helpers.

于 2011-08-15T18:48:25.897 回答
1

大约一年前,我实际上在一个项目中遇到了同样的问题,我也在从事 CI 工作。我刚刚结束了使用 php 的 DateTime 和 DateTimezone 的东西。起初这很棘手,但一点点谷歌搜索有所帮助。也许这会有所帮助?
http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/

于 2011-08-15T18:50:39.910 回答
0

我不使用 CI,但我看到它有一个过滤系统。实现一个过滤器,在控制器运行之前对数据库连接发出 SET TIME_ZONE 查询。您将在用户本地时区从数据库中获取所有日期/时间,而无需对任何控制器、视图或数据库代码进行任何更改。

于 2011-08-15T18:50:54.083 回答