Datetimes in phpBB

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Mvastango
Registered User
Posts: 30
Joined: Wed Jun 09, 2004 12:00 am

Re: Datetimes in phpBB

Post by Mvastango »

Unix timestamps aren't limited, they are just made internally in MySQL to be more space-efficent. As of now (in a time where there is very little need for dates past year 2039), timestamps are stored as INT's, requiring 4 bytes of space each. The DATETIME column in MySQL requires 8 bytes. For those 8 bytes though, you could switch that INT column for a unix timestamp into a BIGINT column. DATETIME columns have a range of year 0 to year 9999. A (signed) BIGINT timestamp would have a range from 299654710078 BCE to 299654714018 CE.

Limited? I think not. ;)
User avatar
NarGemini
Registered User
Posts: 31
Joined: Fri Feb 28, 2003 2:27 am
Location: Phoenix, AZ
Contact:

Re: Datetimes in phpBB

Post by NarGemini »

Actually, I think that the reason that Unix timestamps only go to 2038 is because a timestamp is a 32-bit signed integer. Were timestamps 64-bit, they could encompass just about every date within human comprehension. The creator of ADODB has a nice library here for dates that don't fit into the regular Unix timestamp range. Oh, and as far as birthdays are concerned, a timestamp would appear to be easier because you could calculate a person's age without a problem. Or you could record it in YYYY-MM-DD format in the database and then translate that into a timestamp in PHP if the numbers became too big.
Post Reply