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?

hakre
  • 193,403
  • 52
  • 435
  • 836
jjwdesign
  • 3,272
  • 8
  • 41
  • 66

4 Answers4

2

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

jondavidjohn
  • 61,812
  • 21
  • 118
  • 158
1

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

ldiqual
  • 15,015
  • 6
  • 52
  • 90
  • I'm sure it's been done a couple hundred times before. I see the Date helper for CI; looks interesting. I'm now wondering if using the CI Date help is the better approach, rather than using the PHP5 DateTime classes? – jjwdesign Aug 15 '11 at 19:16
1

I was actually facing the same problem with a project about a year ago, and I was working on CI too. I just ended up using php's DateTime and DateTimezone stuff. It was tricky at first, but a little bit of googling helped. Perhaps this would help?
http://blog.boxedice.com/2009/03/21/handling-timezone-conversion-with-php-datetime/

Munim
  • 6,310
  • 2
  • 35
  • 44
0

I don't use CI but I see it has a filter system. Implement a filter that issues a SET TIME_ZONE query on the DB connection before your controllers run. You'll get all the dates/times out of the database in the user's local time zone without having to make any changes to any controller, view or database code.

Dan Grossman
  • 51,866
  • 10
  • 112
  • 101