Results 1 to 10 of 11
Hybrid View
-
20th Aug 2010, 05:48 AM #1OPMember
user timezone
what the way to display the timezone for user while registering on site and insert in mysql ?
warezrock Reviewed by warezrock on . user timezone what the way to display the timezone for user while registering on site and insert in mysql ?:| Rating: 5Can Do :-
PSD TO ANY CMS | PHP(Dynamic Site) | MySql | Script Customization | cUrl Related Work
Pm me for more info ;)
-
20th Aug 2010, 05:57 AM #2Member
Please give more info , what software you are talking about ?
-
20th Aug 2010, 06:03 AM #3OPMember
well i am not using any software, i am about to make register form for user where he just input username, pass and email to register but i want to integrate the timezone function for user like one have on vbulletin register page TIMEZONE.
i want to know what method is working on backendCan Do :-
PSD TO ANY CMS | PHP(Dynamic Site) | MySql | Script Customization | cUrl Related Work
Pm me for more info ;)
-
20th Aug 2010, 08:53 AM #4MemberWebsite's:
Elite.SO Defendos.com Motionite.comI think there is a mod for diz.
-
20th Aug 2010, 09:15 AM #5OPMember
@l0calh0st
if u have then post it here bro.Can Do :-
PSD TO ANY CMS | PHP(Dynamic Site) | MySql | Script Customization | cUrl Related Work
Pm me for more info ;)
-
20th Aug 2010, 09:16 AM #6MemberWebsite's:
Elite.SO Defendos.com Motionite.comI don't have it.
-
20th Aug 2010, 02:51 PM #7MemberWebsite's:
litewarez.net litewarez.com triniwarez.comthe way how to do this is not very hard.
When your php program first starts to load up it uses the default timezone set in the php.ini witch is usually en-us, the secret is to set the users timezone before any use of the date functions in php. for example
PHP Code:<?php
//Script Head
echo date('l jS \of F Y h:i:s A');
?>
You need to detect the timezone at the head of the script so no matter where you use the use data/time functions there always exact to the user and not the default server time.
PHP Code:class UserLocale
{
var $locale;
var $timezone;
var $languages = array();
public function __construct()
{
//en_US or whatever.
$this->locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
setlocale(LC_ALL, $this->locale); //Set the locale, example below
/*
strftime("%A %e %B %Y", mktime(0, 0, 0, 12, 22, 1978));
Produces: vrijdag 22 december 1978
*/
$this->detectAvailableLanguages();
}
private function detectAvailableLanguages()
{
$langs = array();
if (isset($this->locale))
{
// break up string into pieces (languages and q factors)
preg_match_all(
'/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
$_SERVER['HTTP_ACCEPT_LANGUAGE'],
$lang_parse
);
if (count($lang_parse[1]))
{
// create a list like "en" => 0.8
$this->languages = array_combine($lang_parse[1], $lang_parse[4]);
// set default to 1 for any without q factor
foreach ($this->languages as $lang => $val)
{
if ($val === '') $this->languages[$lang] = 1;
}
// sort list based on value
arsort($this->languages, SORT_NUMERIC);
}
}
}
}
So when you insert a new row into the database you can then use time() witch will produce the time according to the best possible time-zone / locale.
you can also do the same with languages, just detect the language from the http headers and then build a parser to get the available languages.
then create a language folder called en_US and add your language data in there such as strings as such, or you can use a DB to store language strings.
then just load the appropriate language strings according to the headers and then you have a real multilingual site.
Some other good resources:
http://stackoverflow.com/questions/2...-locale-in-php
http://www.php.net/manual/en/functio...mezone-set.php
http://www.php.net/manual/en/locale.acceptfromhttp.php
http://stackoverflow.com/questions/2...uage-using-php
http://www.thefutureoftheweb.com/blo...anguage-headerJoin Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
20th Aug 2010, 05:38 PM #8MemberWebsite's:
litewarez.net litewarez.com triniwarez.comanother way to do this is using the gears API!
here's an example!
Code:var p = {}; function geofind(successCallback, errorCallback) { try { navigator.geolocation.getCurrentPosition(successCallback, errorCallback, { maximumAge: 600000 }); }catch(e) { try { var geolocation = {}; geolocation = google.gears.factory.create('beta.geolocation'); geolocation.getCurrentPosition(successCallback, errorCallback); } catch(e) { try { p.coords = google.loader.ClientLocation; successCallback(p); }catch(e) { errorCallback({ message: "No Geolocation providers found" }); } } } }
Code:geofind(function(result) { //Success $.post('set_geo_location.php',{result},function(){ //ask the user to reload the page as you now have a geo-location in $_SESSION }); }, function(error) { //Error } );
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
-
20th Aug 2010, 09:46 PM #9MemberWebsite's:
epicimagehost.comIn your registration form add:
PHP Code:<select name="TimeZone">
<option value="1">GMT</option>
<option value="2">GMT+1</option>
<option value="3">GMT+2</option>
<option value="4">GMT+ > 9000</option>
etc
</select>
-
21st Aug 2010, 10:32 AM #10MemberWebsite's:
litewarez.net litewarez.com triniwarez.comYea you can ask the user if you wish.
Code:CREATE TABLE `timezones` ( `id` tinyint(3) unsigned NOT NULL auto_increment, `timezone_location` varchar(30) NOT NULL default '', `gmt` varchar(11) NOT NULL default '', `offset` tinyint(2) NOT NULL default '0', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=143 ; -- -- Dumping data for table `timezones` -- INSERT INTO `timezones` VALUES (1, 'International Date Line West', '(GMT-12:00)', -12), (2, 'Midway Island', '(GMT-11:00)', -11), (3, 'Samoa', '(GMT-11:00)', -11), (4, 'Hawaii', '(GMT-10:00)', -10), (5, 'Alaska', '(GMT-09:00)', -9), (6, 'Pacific Time (US & Canada)', '(GMT-08:00)', -8), (7, 'Tijuana', '(GMT-08:00)', -8), (8, 'Arizona', '(GMT-07:00)', -7), (9, 'Mountain Time (US & Canada)', '(GMT-07:00)', -7), (10, 'Chihuahua', '(GMT-07:00)', -7), (11, 'La Paz', '(GMT-07:00)', -7), (12, 'Mazatlan', '(GMT-07:00)', -7), (13, 'Central Time (US & Canada)', '(GMT-06:00)', -6), (14, 'Central America', '(GMT-06:00)', -6), (15, 'Guadalajara', '(GMT-06:00)', -6), (16, 'Mexico City', '(GMT-06:00)', -6), (17, 'Monterrey', '(GMT-06:00)', -6), (18, 'Saskatchewan', '(GMT-06:00)', -6), (19, 'Eastern Time (US & Canada)', '(GMT-05:00)', -5), (20, 'Indiana (East)', '(GMT-05:00)', -5), (21, 'Bogota', '(GMT-05:00)', -5), (22, 'Lima', '(GMT-05:00)', -5), (23, 'Quito', '(GMT-05:00)', -5), (24, 'Atlantic Time (Canada)', '(GMT-04:00)', -4), (25, 'Caracas', '(GMT-04:00)', -4), (26, 'La Paz', '(GMT-04:00)', -4), (27, 'Santiago', '(GMT-04:00)', -4), (28, 'Newfoundland', '(GMT-03:30)', -3), (29, 'Brasilia', '(GMT-03:00)', -3), (30, 'Buenos Aires', '(GMT-03:00)', -3), (31, 'Georgetown', '(GMT-03:00)', -3), (32, 'Greenland', '(GMT-03:00)', -3), (33, 'Mid-Atlantic', '(GMT-02:00)', -2), (34, 'Azores', '(GMT-01:00)', -1), (35, 'Cape Verde Is.', '(GMT-01:00)', -1), (36, 'Casablanca', '(GMT)', 0), (37, 'Dublin', '(GMT)', 0), (38, 'Edinburgh', '(GMT)', 0), (39, 'Lisbon', '(GMT)', 0), (40, 'London', '(GMT)', 0), (41, 'Monrovia', '(GMT)', 0), (42, 'Amsterdam', '(GMT+01:00)', 1), (43, 'Belgrade', '(GMT+01:00)', 1), (44, 'Berlin', '(GMT+01:00)', 1), (45, 'Bern', '(GMT+01:00)', 1), (46, 'Bratislava', '(GMT+01:00)', 1), (47, 'Brussels', '(GMT+01:00)', 1), (48, 'Budapest', '(GMT+01:00)', 1), (49, 'Copenhagen', '(GMT+01:00)', 1), (50, 'Ljubljana', '(GMT+01:00)', 1), (51, 'Madrid', '(GMT+01:00)', 1), (52, 'Paris', '(GMT+01:00)', 1), (53, 'Prague', '(GMT+01:00)', 1), (54, 'Rome', '(GMT+01:00)', 1), (55, 'Sarajevo', '(GMT+01:00)', 1), (56, 'Skopje', '(GMT+01:00)', 1), (57, 'Stockholm', '(GMT+01:00)', 1), (58, 'Vienna', '(GMT+01:00)', 1), (59, 'Warsaw', '(GMT+01:00)', 1), (60, 'West Central Africa', '(GMT+01:00)', 1), (61, 'Zagreb', '(GMT+01:00)', 1), (62, 'Athens', '(GMT+02:00)', 2), (63, 'Bucharest', '(GMT+02:00)', 2), (64, 'Cairo', '(GMT+02:00)', 2), (65, 'Harare', '(GMT+02:00)', 2), (66, 'Helsinki', '(GMT+02:00)', 2), (67, 'Istanbul', '(GMT+02:00)', 2), (68, 'Jerusalem', '(GMT+02:00)', 2), (69, 'Kyev', '(GMT+02:00)', 2), (70, 'Minsk', '(GMT+02:00)', 2), (71, 'Pretoria', '(GMT+02:00)', 2), (72, 'Riga', '(GMT+02:00)', 2), (73, 'Sofia', '(GMT+02:00)', 2), (74, 'Tallinn', '(GMT+02:00)', 2), (75, 'Vilnius', '(GMT+02:00)', 2), (76, 'Baghdad', '(GMT+03:00)', 3), (77, 'Kuwait', '(GMT+03:00)', 3), (78, 'Moscow', '(GMT+03:00)', 3), (79, 'Nairobi', '(GMT+03:00)', 3), (80, 'Riyadh', '(GMT+03:00)', 3), (81, 'St. Petersburg', '(GMT+03:00)', 3), (82, 'Volgograd', '(GMT+03:00)', 3), (83, 'Tehran', '(GMT+03:30)', 3), (84, 'Abu Dhabi', '(GMT+04:00)', 4), (85, 'Baku', '(GMT+04:00)', 4), (86, 'Muscat', '(GMT+04:00)', 4), (87, 'Tbilisi', '(GMT+04:00)', 4), (88, 'Yerevan', '(GMT+04:00)', 4), (89, 'Kabul', '(GMT+04:30)', 4), (90, 'Ekaterinburg', '(GMT+05:00)', 5), (91, 'Islamabad', '(GMT+05:00)', 5), (92, 'Karachi', '(GMT+05:00)', 5), (93, 'Tashkent', '(GMT+05:00)', 5), (94, 'Chennai', '(GMT+05:30)', 5), (95, 'Kolkata', '(GMT+05:30)', 5), (96, 'Mumbai', '(GMT+05:30)', 5), (97, 'New Delhi', '(GMT+05:30)', 5), (98, 'Kathmandu', '(GMT+05:45)', 5), (99, 'Almaty', '(GMT+06:00)', 6), (100, 'Astana', '(GMT+06:00)', 6), (101, 'Dhaka', '(GMT+06:00)', 6), (102, 'Novosibirsk', '(GMT+06:00)', 6), (103, 'Sri Jayawardenepura', '(GMT+06:00)', 6), (104, 'Rangoon', '(GMT+06:30)', 6), (105, 'Bangkok', '(GMT+07:00)', 7), (106, 'Hanoi', '(GMT+07:00)', 7), (107, 'Jakarta', '(GMT+07:00)', 7), (108, 'Krasnoyarsk', '(GMT+07:00)', 7), (109, 'Beijing', '(GMT+08:00)', 8), (110, 'Chongqing', '(GMT+08:00)', 8), (111, 'Hong Kong', '(GMT+08:00)', 8), (112, 'Irkutsk', '(GMT+08:00)', 8), (113, 'Kuala Lumpur', '(GMT+08:00)', 8), (114, 'Perth', '(GMT+08:00)', 8), (115, 'Singapore', '(GMT+08:00)', 8), (116, 'Taipei', '(GMT+08:00)', 8), (117, 'Ulaan Bataar', '(GMT+08:00)', 8), (118, 'Urumqi', '(GMT+08:00)', 8), (119, 'Osaka', '(GMT+09:00)', 9), (120, 'Sapporo', '(GMT+09:00)', 9), (121, 'Seoul', '(GMT+09:00)', 9), (122, 'Tokyo', '(GMT+09:00)', 9), (123, 'Yakutsk', '(GMT+09:00)', 9), (124, 'Adelaide', '(GMT+09:30)', 9), (125, 'Darwin', '(GMT+09:30)', 9), (126, 'Brisbane', '(GMT+10:00)', 10), (127, 'Canberra', '(GMT+10:00)', 10), (128, 'Guam', '(GMT+10:00)', 10), (129, 'Hobart', '(GMT+10:00)', 10), (130, 'Melbourne', '(GMT+10:00)', 10), (131, 'Port Moresby', '(GMT+10:00)', 10), (132, 'Sydney', '(GMT+10:00)', 10), (133, 'Vladivostok', '(GMT+10:00)', 10), (134, 'Magadan', '(GMT+11:00)', 11), (135, 'New Caledonia', '(GMT+11:00)', 11), (136, 'Solomon Is.', '(GMT+11:00)', 11), (137, 'Auckland', '(GMT+12:00)', 12), (138, 'Fiji', '(GMT+12:00)', 12), (139, 'Kamchatka', '(GMT+12:00)', 12), (140, 'Marshall Is.', '(GMT+12:00)', 12), (141, 'Wellington', '(GMT+12:00)', 12), (142, 'Nuku''alofa', '(GMT+13:00)', 13);
PHP Code:var gmtHours = new Date().getTimezoneOffset() / 60;
//jQuery
$('#lselect[rel*='+gmtHours +']').attr('selected','selected');
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
How to change the date.timezone value in PHP?
By Areon in forum Server ManagementReplies: 0Last Post: 20th Mar 2014, 01:07 PM -
Mysql Timezone
By Mr.Mirchi in forum Web Development AreaReplies: 3Last Post: 1st Sep 2012, 06:10 PM -
Ubuntu 10.04 Installtion hangs on timezone screen :(
By sceneguy in forum Server ManagementReplies: 2Last Post: 14th Apr 2012, 05:31 AM -
Big problem with timezone
By Spetsnaz in forum Server ManagementReplies: 4Last Post: 28th Mar 2012, 07:06 AM -
What's the timezone of Hotfile system?
By kohkindachi in forum Webmasters, Money MakingReplies: 3Last Post: 16th Jul 2010, 01:09 PM
themaCreator - create posts from...
Version 3.48 released. Open older version (or...