Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6683479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:49:35+00:00 2026-05-26T04:49:35+00:00

I have a mysql table with data like (name, address, sex, city state, zip,

  • 0

I have a mysql table with data like (name, address, sex, city state, zip, country, timezone) When a user fills in the form to add this data, i would like the relevant time-zone to be added based on state and country, how can i do this?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:49:35+00:00Added an answer on May 26, 2026 at 4:49 am

    Why not have the following select box in your form?

     $list = DateTimeZone::listAbbreviations();
    
        $idents = DateTimeZone::listIdentifiers();
    
        $data = $offset = $added = array();
        foreach ($list as $abbr => $info) {
            foreach ($info as $zone) {
                if ( ! empty($zone['timezone_id'])
                    AND
                    ! in_array($zone['timezone_id'], $added)
                    AND 
                      in_array($zone['timezone_id'], $idents)) {
                    $z = new DateTimeZone($zone['timezone_id']);
                    $c = new DateTime(null, $z);
                    $zone['time'] = $c->format('H:i a');
                    $data[] = $zone;
                    $offset[] = $z->getOffset($c);
                    $added[] = $zone['timezone_id'];
                }
            }
        }
    
        array_multisort($added, SORT_ASC, $data);
        $options = array();
        foreach ($data as $key => $row) {
            $options[$row['timezone_id']] = $row['time'] . ' - '
                                            . formatOffset($row['offset']) 
                                            . ' ' . $row['timezone_id'];
            $values[$row['timezone_id']] = $row['time'] . '/'
                                            . formatOffset($row['offset']) 
                                            . '/' . $row['timezone_id'];
        }
    
    
    function formatOffset($offset) {
            $hours = $offset / 3600;
            $remainder = $offset % 3600;
            $sign = $hours > 0 ? '+' : '-';
            $hour = (int) abs($hours);
            $minutes = (int) abs($remainder / 60);
    
            if ($hour == 0 AND $minutes == 0) {
                $sign = ' ';
            }
            return 'GMT' . $sign . str_pad($hour, 2, '0', STR_PAD_LEFT) 
                    .':'. str_pad($minutes,2, '0');
    
    }
    
    echo "<select name='locale'>";
    foreach($options as $key=>$value){
        echo "<option value='".$values[$key]."'>".$value."</option>";
    }
    echo "</select>";
    

    This would handle the fact there are states with multiple timezones. When you then get the result of this form submission, you can explode the value of the field on ‘/’, where $_POST['locale'] is the handler for the chosen select option, then you can extract timezone, country and state from a single field.

    $locale=explode("/",$_POST['locale']);
    // $locale[0] = timezone
    // $locale[1] = country
    // $locale[2-n] = state(s)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table in MYSQL It has data like Id Name 1 test
I have a mysql table , which holds data like this. Name |how_out |runs
I have three tables, table one (tableA) containing users data like name and email,
I have mysql table with collumns like 'operation.date', 'operation.name' and etc. After fetching that
I have a MySQL table with the following data (simplified): INSERT INTO `stores` (`storeId`,
I have a MySQL table with a tree data structure. The fields are _id
I have a mysql table field set as time type which stores data in
When showing data from a mysql table on an php page does it have
I have an application that shows data from a MySQL table. Basically, my application
I have MySQL InnoDB table utf-8 encoded. This table has only id and name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.