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!
User avatar
skrypt
Registered User
Posts: 34
Joined: Wed May 05, 2004 4:39 am
Location: Québec, Canada
Contact:

Datetimes in phpBB

Post by skrypt »

I whas asking myself, since the phpBB is using unixtime stamp what are we doing for dates that are under 1970 01-01 00:00:00.
I mean dates are stored in the database following this algorith:
GMTdate - 1970 01-01 00:00:00 = X seconds.
But if I would like to store birthdates in database and things like that is it going to work :?:

Yoshi 15
Registered User
Posts: 86
Joined: Sun Jun 29, 2003 10:04 pm

Re: Datetimes in phpBB

Post by Yoshi 15 »

Maybe negative timestamps?

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: Datetimes in phpBB

Post by Arty »

Why would you want to use time_t for birthdays? That format is for complete time including seconds and you need only date without time.

User avatar
skrypt
Registered User
Posts: 34
Joined: Wed May 05, 2004 4:39 am
Location: Québec, Canada
Contact:

Re: Datetimes in phpBB

Post by skrypt »

CyberAlien wrote:Why would you want to use time_t for birthdays
For multi-database support.

In Access, SQL statements for an INSERT of a date is:
INSERT INTO Table (datetime_field) VALUES (#01/01/1970 00:00:00#)
and in MySQL
INSERT INTO Table (datetime_field) VALUES ('01/01/1970 00:00:00')

So if you store only a value who's a number you don't need a DATETIME field in your database, you replace it with a field who support LONG values.
In the MySQL database right now Dates are stored as INT(11) values.

User avatar
th23
Registered User
Posts: 112
Joined: Sat Jul 03, 2004 4:26 pm
Location: Bonn, Germany
Contact:

Re: Datetimes in phpBB

Post by th23 »

As CyberAlien wrote: These type of fields int(11) is not made to store something before 1970 in it. If you want to store a birthday I would recommend a varchar field, size 10 using the form "1977-05-21"... as it is done in phpBB 2.2 (I just looked up)

th23

User avatar
skrypt
Registered User
Posts: 34
Joined: Wed May 05, 2004 4:39 am
Location: Québec, Canada
Contact:

Re: Datetimes in phpBB

Post by skrypt »

Thanks, now I understand 8)

Th0maz
Registered User
Posts: 2
Joined: Sun Jul 18, 2004 12:46 am

Re: Datetimes in phpBB

Post by Th0maz »

Date: 12/05/720 10h12m30s
Stamp: -39416939250

... wouldn't fit int(11) though

Smirnov
Registered User
Posts: 14
Joined: Thu Mar 21, 2002 12:14 am
Contact:

Re: Datetimes in phpBB

Post by Smirnov »

Why don't they just use the TIMESTAMP column type? It's the easiest.. and times are in a simple to read manner:
20040828125323 would be the timestamp on my computer right now :).

Thats:
YYYYMMDDhhmmss

User avatar
A_Jelly_Doughnut
Registered User
Posts: 1780
Joined: Wed Jun 04, 2003 4:23 pm

Re: Datetimes in phpBB

Post by A_Jelly_Doughnut »

As far as I know, only MySQL has a TIMESTAMP data type. THerefore, using a TIMESTAMP would either require workarounds for other DBMS or dropping support for them altogether.
A_Jelly_Doughnut

User avatar
Ptirhiik_
Registered User
Posts: 526
Joined: Tue Nov 18, 2003 8:35 am

Re: Datetimes in phpBB

Post by Ptirhiik_ »

Negative timestamp is not supported by mycrosoft or ibm server, what is quite logical the way this date is computed (negative values is equivalent to add one digit to type length). unix timestamp is a very limited format (there is also a max value, not only a min value) which prevent date getting over 30 years from now. Therefore, using a unix timestamp for a secular date wouldn't be a smart move ;).

Post Reply