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 7867057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:36:18+00:00 2026-06-03T00:36:18+00:00

I am developing an API using php where I just send out the query

  • 0

I am developing an API using php where I just send out the query result as JSON string. The result is combination of multiple tables. However, one of the field is Time. I need to convert this to a different timezones based on the timezone setting from a different table.

Here is the current output:

     Array ( "Show_name" => "Billards",
             "Show_type" => "Movie",
             "Start_Time" => "2011-11-09 07:00:00",
             "End_Time" => "2011-11-09 09:00:00",
             "Open" => "Yes"
           );

Start time and end time are in EST for all records by default. Timezone settings are stored in a different table with fields Timezone_ID, GMT_offset, DST_offset. Based on these settings start_time and end_time, which are in est by default, should be converted to respective timezones.

I was initially planning to write a MySQL function to calculate this right from the query itself, that way the JSON format / fields do not change. But I see that, its way too slow compared to PHP function.

What do you suggest based on your experience?
– Is there a way to simply calculate with in the query?
– Does MySQL functions perform better than PHP?
– If I need to go with php function, I need to loop through all records to calculate this. Not sure if I need to pull the timezone record separately. Because I don’t want to change the format / number of fields in the JSON response.

Any other better way?

  • 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-06-03T00:36:20+00:00Added an answer on June 3, 2026 at 12:36 am

    I generally do this on the database side. Note that I store all dates in the database as UTC.

    So, to display data to the user in the user’s local time zone, I do something like this:

    SELECT Show_name, Show_type,
      Start_time, CONVERT_TZ(Start_time, 'UTC', 'EST') AS Start_time_local
    FROM Shows
    

    Where ‘EST’ is the timezone that the user has selected in their preferences.

    Changing your dates in the database from EST to UTC does not require any schema change, as the timezone is not stored in the schema.

    To convert all your dates from EST to UTC, simply do this:

    UPDATE Shows
    SET Start_time = CONVERT_TZ(Start_time, 'EST', 'UTC')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Twitter API with PHP, developing sort of tests. Those test are one
I am developing an API using PHP (Codeigniter) and Phils RESTserver. I am creating
I'm developing an API using Luracast Restler library. All I'm looking for is to
I'm developing a API that uses lambda expressions to specify properties. I'm using this
I am developing an custom API for a web solution and I am using
I'm developing a twitter messaging utility using Twitter API (twitterizer). But since I'm within
I'm developing a fun little project using Foursquare API. In this project, I have
I am developing an API using Codeigniter and MongoDB. I am not sure what
I am developing a web api using WCF Web Api preview 5. At the
We are developing a restful api using jersey (1.9.1) and tomcat 5.5. A given

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.