Jump to content

Archived

This topic is now archived and is closed to further replies.

mak-uk

Quick DATE question guys/girls

Recommended Posts

Hi

 

I want to store the mJoinDate and mLastLogin of a particular user.

 

Initially, I had for the first field:

[php:1:b3f9e28bcf]`mJoinDate` timestamp(14) NOT NULL,[/php:1:b3f9e28bcf]

 

Then, when I realised I need mLastLogin, I saw a tutorial and in that they were both as:

[php:1:b3f9e28bcf]signup_date datetime NOT NULL default \'0000-00-00 00:00:00\',

last_login datetime NOT NULL default \'0000-00-00 00:00:00\', [/php:1:b3f9e28bcf]

So what I am wondering is, which \'type\' should I use - timestamp or datetime?

 

Thanks.

 

Mak :)

Share this post


Link to post
Share on other sites

I would personally use the second option:

 

signup_date datetime NOT NULL default \'0000-00-00 00:00:00\',

last_login datetime NOT NULL default \'0000-00-00 00:00:00\',

 

Cheers :roll:

Share this post


Link to post
Share on other sites

Hi

 

Any particular reason for choosing them rather than TIMESTAMP?

 

Thanks.

 

Mak :)

Share this post


Link to post
Share on other sites

Use timestamp when you want to record when the record was added or last updated. This will happen automatically if you do not write a value to it (or write NULL to it). (But only for one timestamp field per record).

 

If the time is not relevant, just use DATE type (eg birthdays, date joined etc)

 

hth

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.