Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Wordpress using two column to store post date

I see wordpress database on wp_posts table, there are 2 columns to store post date, post_date and post_date_gmt

post_date_gmt store the post date in GMT time. And post_date store post date in user time who create the post. Am I right?

Is there any benefit to store both version of post date on database?

Is it faster to store both version of post date rather than calculate post_date_gmt with user timezone when user want to view post date based on his/her timezone

UPDATE: I Also ask on site point and get this answer

The one benefit it would provide is that if the person moves to a different timezone then their earlier posts still record what time it was where they were when they posted them and not what time it was where they are now (as would be all you could calculate using the GMT time and their current timezone).

http://www.sitepoint.com/forums/showthread.php?p=4671837

like image 944
Permana Avatar asked Aug 13 '10 07:08

Permana


2 Answers

Not sure about the speed on the interpreter. One big reason they use GMT is actually that it makes the date-time more portable and not tied to a specific timezone and allows you to write code that is more general and internationalized. Why they save both is curious but the GMT format is definitely preferred for database storage.

like image 54
h3r2on Avatar answered Sep 29 '22 23:09

h3r2on


Thats because some countries use Daylight Saving Time

like image 40
PrivateUser Avatar answered Sep 30 '22 01:09

PrivateUser