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.
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.