Quantcast
Channel: Should I use the datetime or timestamp data type in MySQL? - Stack Overflow
Browsing latest articles
Browse All 41 View Live

Answer by Ronald Aaronson for Should I use the datetime or timestamp data...

A DATETIME carries no timezone information with it and will always display the same independent of the timezone that is in effect for the session, which defaults to the server's timezone unless you...

View Article



Answer by Wilson Hauck for Should I use the datetime or timestamp data type...

If you want to GUARANTEE your application will NOT function in February, 2038, use TIMESTAMP. Refer to your REFMAN for the RANGE of dates supported.

View Article

Answer by Accountant م for Should I use the datetime or timestamp data type...

I stopped using datetime in my applications after facing many problems and bugs related to time zones. IMHO using timestamp is better than datetime in most of the cases. When you ask what is the time ?...

View Article

Answer by curiosity for Should I use the datetime or timestamp data type in...

timestamp is a current time of an event recorded by a computer through Network Time Protocol (NTP). datetime is a current timezone that is set in your PHP configuration.

View Article

Answer by Premraj for Should I use the datetime or timestamp data type in MySQL?

+---------------------------------------------------------------------------------------+--------------------------------------------------------------------------+ | TIMESTAMP | DATETIME |...

View Article


Image may be NSFW.
Clik here to view.

Answer by Dehan de Croos for Should I use the datetime or timestamp data type...

Comparison between DATETIME, TIMESTAMP and DATE What is that [.fraction]? A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision. In...

View Article

Answer by rogerpro for Should I use the datetime or timestamp data type in...

In my case, I set UTC as a time zone for everything: the system, the database server, etc. every time that I can. If my customer requires another time zone, then I configure it on the app. I almost...

View Article

Answer by Elliptical view for Should I use the datetime or timestamp data...

Not mentioned so far, is that DEFAULT CURRENT_TIMESTAMP only works with Timestamp, but not DateTime type fields. This becomes relevant for MS Access tables which can only use DateTime but not Timestamp.

View Article


Answer by Mahdi Jazini for Should I use the datetime or timestamp data type...

TIMESTAMP is useful when you have visitors from different countries with different time zones. you can easily convert the TIMESTAMP to any country time zone

View Article


Answer by Matthew for Should I use the datetime or timestamp data type in MySQL?

A lot of answers here suggest to store as timestamp in the case you have to represent well defined points in time. But you can also have points in time with datetime if you store them all in UTC by...

View Article

Answer by Mwangi Thiga for Should I use the datetime or timestamp data type...

A TIMESTAMP requires 4 bytes, whereas a DATETIME requires 8 bytes.

View Article

Answer by Martin Zeitler for Should I use the datetime or timestamp data type...

I merely use unsigned BIGINT while storing UTC ... which then still can be adjusted to local time in PHP. the DATETIME to be selected with FROM_UNIXTIME( integer_timestamp_column ). one obviously...

View Article

Answer by Sebastien Horin for Should I use the datetime or timestamp data...

2016 +: what I advise is to set your Mysql timezone to UTC and use DATETIME: Any recent front-end framework (Angular 1/2, react, Vue,...) can easily and automatically convert your UTC datetime to local...

View Article


Answer by Anvesh for Should I use the datetime or timestamp data type in MySQL?

Reference taken from this Article: The main differences: TIMESTAMP used to track changes to records, and update every time when the record is changed. DATETIME used to store specific and static value...

View Article

Answer by user64141 for Should I use the datetime or timestamp data type in...

I recommend using neither a DATETIME or a TIMESTAMP field. If you want to represent a specific day as a whole (like a birthday), then use a DATE type, but if you're being more specific than that,...

View Article


Answer by Charles Faiga for Should I use the datetime or timestamp data type...

The major difference is a INDEX's on Timestamp - works a INDEX's on Datetime - Does not work look at this post to see problems with Datetime indexing

View Article

Answer by ecleel for Should I use the datetime or timestamp data type in MySQL?

Another difference between Timestamp and Datetime is in Timestamp you can't default value to NULL.

View Article


Answer by Vivek S for Should I use the datetime or timestamp data type in MySQL?

TIMESTAMP is four bytes vs eight bytes for DATETIME. Timestamps are also lighter on the database and indexed faster. The DATETIME type is used when you need values that contain both date and time...

View Article

Answer by Lloyd Banks for Should I use the datetime or timestamp data type in...

Beware of timestamp changing when you do a UPDATE statement on a table. If you have a table with columns 'Name' (varchar), 'Age' (int), and 'Date_Added' (timestamp) and you run the following DML...

View Article

Answer by Arvind for Should I use the datetime or timestamp data type in MySQL?

The timestamp data type stores date and time, but in UTC format, not in the current timezone format as datetime does. And when you fetch data, timestamp again converts that into the current timezone...

View Article

Answer by Kannan Prasad for Should I use the datetime or timestamp data type...

From my experiences, if you want a date field in which insertion happens only once and you don't want to have any update or any other action on that particular field, go with date time. For example,...

View Article


Answer by leejmurphy for Should I use the datetime or timestamp data type in...

It is worth noting in MySQL you can use something along the lines of the below when creating your table columns: on update CURRENT_TIMESTAMP This will update the time at each instance you modify a row...

View Article


Answer by Oliver Holmberg for Should I use the datetime or timestamp data...

I always use a Unix timestamp, simply to maintain sanity when dealing with a lot of datetime information, especially when performing adjustments for timezones, adding/subtracting dates, and the like....

View Article

Answer by Marc DiMillo for Should I use the datetime or timestamp data type...

I found unsurpassed usefulness in TIMESTAMP's ability to auto update itself based on the current time without the use of unnecessary triggers. That's just me though, although TIMESTAMP is UTC like it...

View Article

Answer by mr_eclair for Should I use the datetime or timestamp data type in...

The below examples show how the TIMESTAMP date type changed the values after changing the time-zone to 'america/new_york' where DATETIMEis unchanged. mysql> show variables like '%time_zone%';...

View Article


Answer by user723220 for Should I use the datetime or timestamp data type in...

I like a Unix timestamp, because you can convert to numbers and just worry about the number. Plus you add/subtract and get durations, etc. Then convert the result to Date in whatever format. This code...

View Article

Answer by ianaré for Should I use the datetime or timestamp data type in MySQL?

Depends on application, really. Consider setting a timestamp by a user to a server in New York, for an appointment in Sanghai. Now when the user connects in Sanghai, he accesses the same appointment...

View Article

Answer by Sobes for Should I use the datetime or timestamp data type in MySQL?

TIMESTAMP is always in UTC (that is, elapsed seconds since 1970-01-01, in UTC), and your MySQL server auto-converts it to the date/time for the connection timezone. In the long-term, TIMESTAMP is the...

View Article

Answer by ekerner for Should I use the datetime or timestamp data type in MySQL?

The main difference is that DATETIME is constant while TIMESTAMP is affected by the time_zone setting. So it only matters when you have — or may in the future have — synchronized clusters across time...

View Article



Answer by Nir for Should I use the datetime or timestamp data type in MySQL?

In MySQL 5 and above, TIMESTAMP values are converted from the current time zone to UTC for storage, and converted back from UTC to the current time zone for retrieval. (This occurs only for the...

View Article

Answer by Alex for Should I use the datetime or timestamp data type in MySQL?

TIMESTAMP is 4 bytes Vs 8 bytes for DATETIME. http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html But like scronide said it does have a lower limit of the year 1970. It's great for...

View Article

Answer by Hans for Should I use the datetime or timestamp data type in MySQL?

I prefer using timestamp so to keep everything in one common raw format and format the data in PHP code or in your SQL query. There are instances where it comes in handy in your code to keep everything...

View Article

Answer by scronide for Should I use the datetime or timestamp data type in...

I always use DATETIME fields for anything other than row metadata (date created or modified). As mentioned in the MySQL documentation: The DATETIME type is used when you need values that contain both...

View Article


Answer by unbeknown for Should I use the datetime or timestamp data type in...

I make this decision on a semantic base. I use a timestamp when I need to record a (more or less) fixed point in time. For example when a record was inserted into the database or when some user action...

View Article

Answer by blivet for Should I use the datetime or timestamp data type in MySQL?

Timestamps in MySQL are generally used to track changes to records, and are often updated every time the record is changed. If you want to store a specific value you should use a datetime field. If you...

View Article

Answer by Jeff Warnica for Should I use the datetime or timestamp data type...

A timestamp field is a special case of the datetime field. You can create timestamp columns to have special properties; it can be set to update itself on either create and/or update. In "bigger"...

View Article


Answer by Mark Davidson for Should I use the datetime or timestamp data type...

I would always use a Unix timestamp when working with MySQL and PHP. The main reason for this being the the default date method in PHP uses a timestamp as the parameter, so there would be no parsing...

View Article


Should I use the datetime or timestamp data type in MySQL?

Would you recommend using a datetime or a timestamp field, and why (using MySQL)? I'm working with PHP on the server side.

View Article

Answer by Bloody Programmer for Should I use the datetime or timestamp data...

DATETIME vs TIMESTAMP:TIMESTAMP used to track changes of records, and update every time when the record is changed.DATETIME used to store specific and static value which is not affected by any changes...

View Article

Answer by William Entriken for Should I use the datetime or timestamp data...

Neither. The DATETIME and TIMESTAMP types are fundamentally broken for generic use cases. MySQL will change them in the future. You should use BIGINT and UNIX timestamps unless you have a specific...

View Article

--- Article Not Found! ---

*** *** *** RSSing Note: Article is missing! We don't know where we put it!!. *** ***

View Article

Browsing latest articles
Browse All 41 View Live




Latest Images