Skip to content

Instantly share code, notes, and snippets.

@joshsmith
Created October 6, 2010 04:55
Show Gist options
  • Save joshsmith/612850 to your computer and use it in GitHub Desktop.
Save joshsmith/612850 to your computer and use it in GitHub Desktop.
<?php
foreach($tzlist as $items) {
foreach($items as $item) {
echo "INSERT INTO timezones (timezone) VALUES ('" . $item . "');";
}
}
<?php
static $regions = array(
'Africa' => DateTimeZone::AFRICA,
'America' => DateTimeZone::AMERICA,
'Antarctica' => DateTimeZone::ANTARCTICA,
'Aisa' => DateTimeZone::ASIA,
'Atlantic' => DateTimeZone::ATLANTIC,
'Europe' => DateTimeZone::EUROPE,
'Indian' => DateTimeZone::INDIAN,
'Pacific' => DateTimeZone::PACIFIC
);
foreach ($regions as $name => $mask) {
$tzlist[] = DateTimeZone::listIdentifiers($mask);
}
echo '<select>';
echo '<option>Pick your timezone</option>';
$count = 0;
foreach($tzlist as $timezones) {
foreach($timezones as $timezone) {
echo '<option value="' . ++$count . '">' . $timezone . '</option>';
}
}
echo '</select>';
CREATE TABLE timezones (
tid INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
timezone VARCHAR(30) NOT NULL
) ENGINE=InnoDB;
CREATE TABLE users_timezones (
uid INT(11) NOT NULL,
tid INT(11) NOT NULL,
FOREIGN KEY (uid) REFERENCES users(uid),
FOREIGN KEY (tid) REFERENCES timezones(tid)
) ENGINE=InnoDB;
<?php
$len = strlen('America/Argentina/Rio_Gallegos');
echo $len;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment