CyberJunkie
CyberJunkie

Reputation: 22684

Using Codeigniter date helper to get timezone location

I'm using the Codeigniter date helper for timezone functions. I want to display a user's timezone location based on their timezone reference that I'm saving in the database.

Example:

Take a timezone reference UP1 and return the corresponding location (UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome. Date helper does not have a function for that.

The function could be executed like this..

echo timezone_location('UP1');

which will echo

(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome

Codeigniter's timezone data exists in the folder system/langauge/englishdate_lang.php but I'm not sure how to access that to build the function. What do you think?

Upvotes: 2

Views: 1969

Answers (2)

Josnidhin
Josnidhin

Reputation: 12504

CI stores it the language file system/language/english/date_lang.php

So you could do the following

// load the language file
$this->lang->load('date', 'english');
// will output (UTC -12:00) Baker/Howland Island
echo $this->lang->line('UM12');

Upvotes: 3

Laurence
Laurence

Reputation: 60058

$this->load->helper('language');
$this->lang->load('date', 'english');
echo (lang('UM7')); //gives "(UTC -7:00) Mountain Standard Time"

Upvotes: 2

Related Questions