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

  • Home
  • SEARCH
  • 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 540201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:12:57+00:00 2026-05-13T10:12:57+00:00

I am totally 100% stuck on this, no answer ever given for timezone support

  • 0

I am totally 100% stuck on this, no answer ever given for timezone support in PHP/MySQL has worked 100% for me, so I am asking the question again on here in as much detail as I possibly can with code sample.

Below is what I have so far, please read the comments to see what kind of issues I am having. Basically I can show a date and time in the user’s timezone if it is in the form of a timestamp like this "1262819848" but the NEWER versions of MySQL return a TIMESTAMP like this instead "2010-01-06 23:17:28".

If I could pass "2010-01-06 23:17:28" into this date("m:d:y h:i:s A",$time_stamp) then things would work GREAT but instead it needs a timestamp passed in. The only way I can do this is to either store a real timestamp in an INTEGER field in MySQL OR else get the value "2010-01-06 23:17:28" and then convert it to a timestamp which just seems like to much overhead when I can store it already converted in an INT field.

<?PHP
/////////////////////////////////////////////////////////
//   Get a MySQL time / date and show in user timezone //
////////////////////////////////////////////////////////

//set the user's time zone for this page
//this assumes the user has already chosen a timezone and we are getting it from a PHP session value now
// example value is "America/New_York" which is -5
date_default_timezone_set($_SESSION['time_zone']);

// get a MySQL result with a time/date value in it
$sql = 'SELECT user_id,date from online_users WHERE user_id = 1';
$result = executeQuery($sql);

// set our date/time value from MySQL into a variable
if ($line_online = mysql_fetch_assoc($result)){
    $time_stamp = $line_online['date'];
}

// format our date/time value TIMESTAMP any way we like now!
// MySQL result MUST be in this format '1262291376'
$date_format = date("m:d:y h:i:s A",$time_stamp); // formats timestamp in mm:dd:yy 
echo $date_format;


/////////////////////////////////////////////////////////
//   Add a time / date to MySQL                       //
////////////////////////////////////////////////////////

// this add a time and date to MySQL and looks like this in the MySQL table "2010-01-06 23:17:28"
// that is a TIMESTAMP field in MySQL, newer version of mysql store a timestamp like this "2010-01-06 23:17:28" instead of like this "1262819848"
$sql = "INSERT INTO users (`id`, `datetime`) VALUES ('', UTC_TIMESTAMP())";
executeQuery($sql);

// So if I query this record and try to show it like I do in the code above in the "Get mysql result section" It will not work correctly because  
// because it is like this "2010-01-06 23:17:28" instead of like this "1262819848"
// The ONLY solution I have found is to store the UTC timestamp into an INTEGER field instead of a DATETIME or TIMESTAMP field.
// Everyone on this site says this is wrong and I could use the default date and time stuff but I have yet to get it working.
// If I could store a timestamp in mysql like a timestamp with no "-" dashes in it, then it would work correctly when I show it on page.
// Basicly I have this half done, I can show the time and date in a users timezone as long as I pass the PHP a real TIMESTAMP like this "1262819848"

?>
  • 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-13T10:12:57+00:00Added an answer on May 13, 2026 at 10:12 am

    strtotime() in PHP is a way to pass database datetime format into a UNIX epoch timestamp in PHP. It reads understandable and standard formats and converts into UNIX epoch timestamp, which can be later used by other datetime functions in php such as date().

    Alternatives can be as such:

    UNIX_TIMESTAMP() function in MySQL helps you to convert a specific column datetime or timestamp value into UNIX timestamp. As mentioned at Datetime To Unix timestamp it can be a little faster because this is done on the MySQL server side.

    This seems more of a timestamp than timezone question.

    See more:

    http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

    http://www.php.net/strtotime

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.