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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:32:49+00:00 2026-05-29T11:32:49+00:00

i have a created field in datetime and a modified field in timestamp. this

  • 0

i have a created field in datetime and a modified field in timestamp.
this is my code

date_default_timezone_set('America/Los_Angeles');
if ($this->isNewRecord)
$this->created = date("Y-m-d h:i:s");
$this->modified = date("Y-m-d h:i:s");

when i create a new record i see datetime and timestamp with same time in Los Angeles time but i expect timestamp field to be in UTC.
i mean if datetime field is something like ‘.. 08:00:00′ timestamp should be ’16:00:00’ because US time is (UTC -08:00) and DOC says

TIMESTAMP values are converted from the current time zone to UTC for
storage

  • 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-29T11:32:50+00:00Added an answer on May 29, 2026 at 11:32 am

    TIMESTAMP fieds are in fact converted to UTC for storage. That means, it’s stored this way, but when selected it will be converted to connection’s timezone. You can do an experiment: change your timezone (see below) to something else, and do the select for that timestamp.

    Here’s MySQL docs about handling timezones


    added: some console output for illustration

    mysql> use test
    Database changed
    mysql> -- Let s see what is the current timezone setting on this server
    mysql> SELECT @@global.time_zone, @@session.time_zone;
    +--------------------+---------------------+
    | @@global.time_zone | @@session.time_zone |
    +--------------------+---------------------+
    | SYSTEM             | SYSTEM              |
    +--------------------+---------------------+
    1 row in set (0.00 sec)
    
    mysql> -- I don t know what SYSTEM is set to, so just to be safe I ll set it to my timezone
    mysql> set time_zone = '+01:00';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> SELECT @@global.time_zone, @@session.time_zone;
    +--------------------+---------------------+
    | @@global.time_zone | @@session.time_zone |
    +--------------------+---------------------+
    | SYSTEM             | +01:00              |
    +--------------------+---------------------+
    1 row in set (0.00 sec)
    
    mysql> -- Let s create a table for or test    
    mysql> create table testTimestamp (ts timestamp);
    Query OK, 0 rows affected (0.28 sec)
    
    mysql> -- Now to insert current time into the test table
    mysql> insert into testTimestamp values (now());
    Query OK, 1 row affected (0.01 sec)
    
    mysql> -- Let s see how it looks like
    mysql> select * from testTimestamp;
    +---------------------+
    | ts                  |
    +---------------------+
    | 2012-02-13 00:12:00 |
    +---------------------+
    1 row in set (0.03 sec)
    
    mysql> -- Now let s change session timezone to Los Angeles time
    mysql> set time_zone = '-08:00';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> -- And let s look at our timestamp once again
    mysql> select * from testTimestamp;
    +---------------------+
    | ts                  |
    +---------------------+
    | 2012-02-12 15:12:00 |
    +---------------------+
    1 row in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a datetime field, how do I get just records created later
I have created the following view for users to create new items. Ive tried
hey guys, i have created a stored procedure, wherein i have datetime field in
I have a 'created_date' DATETIME field which I would like to be populated with
We have created a table with a trigger that updates a ModifiedDate field in
I have a field object and I create a list of fields: class Field
I have created a simple project where everyone can create one or more Blog.
For Django 1.1. I have this in my models.py: class User(models.Model): created = models.DateTimeField(auto_now_add=True)
I have a table with a datetime field. I want to retrieve a result
We have a very simple payments model with the default created_at datetime field that

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.