Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm using CodeIgniter and I have tons of date('format',strtotime(unixtimestamp)) methods in my views.

So when user choose his own language and I would like to automatically convert all datetimes to locale time zone for all my views.

Is there any recursive way to make this possible?

The infos i get from users is their selected language:
it = Italian
fr = French
es = Espanol
etc... so i get lang key codes

I sincerely can't get anything out of my head.

Any help appreciated, really. Thanks.

share|improve this question
up vote 1 down vote accepted

Depending how you store the timezone preference, you could use date_default_timezone_set().

For example:

date_default_timezone_set('America/New_York');

Note: I'm not familiar with CodeIgnitor, but so long as you set this in a bootstrap or config script, that is before you call date(), this will automatically display all dates in the set locale.

share|improve this answer
    
yes sorry, check i edited my question with infos i get from users probably i need somenthing different !? – sbaaaang Jul 29 '13 at 18:05
    
oh sorry note i'm using php method datetime() to ouput dates, so i'm not using the date helper – sbaaaang Jul 29 '13 at 18:06
    
The DateTime class you mean? Again, I'm not familiar with CodeIgnitor. – Jason McCreary Jul 29 '13 at 18:08
    
eheh nope, php datetime() php native ;) – sbaaaang Jul 29 '13 at 19:27
    
There is no such function, datetime() in PHP. – Jason McCreary Jul 29 '13 at 19:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.