Jump to content


Photo

Quick DATE question guys/girls


  • Please log in to reply
3 replies to this topic

#1 mak-uk

mak-uk
  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationEngland, UK

Posted 19 July 2003 - 02:36 PM

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 :)

#2 mitsimic

mitsimic
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 25 July 2003 - 01:40 PM

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:

#3 mak-uk

mak-uk
  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationEngland, UK

Posted 25 July 2003 - 07:59 PM

Hi

Any particular reason for choosing them rather than TIMESTAMP?

Thanks.

Mak :)

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 27 July 2003 - 04:39 PM

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
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users