Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am sure this is explained in the documentation, but I could not find it: when I want to add a date field to a content type I get to choose between "Date", "Datetime" and "Datestamp". They all give me the same list of available widgets. So what is the difference? For what purpose should I choose which type?
Comments
Comment #1
choster CreditAttribution: choster commentedThere is a difference as to how they are stored with the database.
From http://drupal.org/node/269813 :
"The ISO date is useful if you want to store incomplete dates, like year and month only. The datetime field is better when you are storing complete dates." Datestamp is available for legacy installations.
Comment #2
gustav CreditAttribution: gustav commentedchoster, thank you very much for that link. So if I understand correctly, all three field types provide exactly the same functionality, only they will be doing it with different efficiency due to the different choice of format for saving the date in the database. Is that right? If so, Karen, with your intimite knowledge of how you have designed the code, can you tell us which type is the most efficient for calendar-type events with minute-level granularity start and end dates on a site where all users are in the same time zone? I assume it must make a difference because otherwise you would not bother to support three different formats.
Comment #4
FreddieK CreditAttribution: FreddieK commentedHah, I also wonder about Date, Datestamp and Datetime. The discussions I see only mentions the two latter, but doesn't mention the first?
Comment #5
msielskiFor anyone finding this page through search, the Date documentation has been updated to explain the difference between these fields. Scroll down to the Date Fields section of this page.
Comment #6
halefxThanks, msielski