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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:59:07+00:00 2026-05-13T09:59:07+00:00

I read a mysql timestamp can only hold a value from 19700101000000 to sometime

  • 0

I read a mysql timestamp can only hold a value from 19700101000000 to sometime in the year 2037. I seriously doubt my app will be around then, well i’m sure it wont but any idea what will people use then for a timestamp, a text field?

Below is an example of how I currently insert a mysql record with a datetime mysql field and you can see I use now() in the PHP below, now I am re-coding my site and I am going to offer timezone support for showing correct times to users so I needd to save date and time as a UTC timestamp.

<?PHP
$sql = "INSERT INTO online_users 
    (user_id,
    online_id,
    ip,
    datetime,
    location,
    gender) 
    values ('$cache->userid,$unid,$LOCALIP,NOW(),$location,$g)";
executeQuery($sql);
?>

Based on my code above and my information above, how would I format this code to insert the time and date into UTC and should I use a timestamp field or a text field in MySQL? I will need to modify the time in my php when showing it often, for example on some posts I calculate the time that has passed since the mysql time (2 days and 4 hours and 34 seconds ago). I also need to use time to query for things like users in the past week to sign on. I am not asking how to do that stuff I just posted it to show what I will be using time for just in case that would help determine the best method I should be saving it as.

  • 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-13T09:59:07+00:00Added an answer on May 13, 2026 at 9:59 am

    I tried everything mention in this question/answer but nothing worked correctly, in the end the only way I was able to get php timezones date_default_timezone_set() function to work correctly with my date and times from mysql was to store them as an integer and then it works perfect. There is no problem of slower sorting for me because I sort by ID number instead of date but to sort by a date I don’t think would be too difficult once I figure out how many seconds are in between.

    When I use an integer field in mysql, I can store a UTC timestamp as this 1262658989. When you use a timestamp or datetime field in mysql, it automatically convert it to this style 2003-04-14 00:00:00 which then makes it much hard to work with timezones for some reason.

    Using an integer instead I can get the UTC timestamp in PHP using this code:

    gmdate('U', time())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A MySQL timestamp field is written and read as 'yyyy-MM-dd hh:mm:ss', how can I
I can read the MySQL documentation and it's pretty clear. But, how does one
I've got a source database (Sybase), which is read-only and you can write to
When doing an ALTER TABLE statement in MySQL, the whole table is read-locked (allowing
I'm just trying to get MySQL to store time in GMT... I've read the
can a MySQL slave instance have different row values for the same ID when
I've read previously that SELECT COUNT(*) is not performant in MySQL and should be
I'm using MySQL and a web-service connect to the database to read some values.
I read this PHP RegEx page , but either I'm missing something, misreading something,
Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service

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.