LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-07-2005, 08:17 PM   #1
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Rep: Reputation: 121Reputation: 121
MySQL data type question: timestamp versus integer to hold time


I am designing and programming a PHP/MySQL application that implements an interactive link directory application where users can register and submit links.

My question is simple. I am using a field to store the time of registration, time a link is submitted etc. in my tables in the MySQL database.

Which type is better for this field: integer or timestamp?
 
Old 07-07-2005, 08:26 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
What would the integer represent, seconds since epoch? :}


Cheers,
Tink
 
Old 07-07-2005, 08:52 PM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Original Poster
Rep: Reputation: 121Reputation: 121
Hmm... yes. The PHP time() function returns in seconds. To use timestamp I must convert it to a format.

I think integer is better, but what are the advantages of using timestamp over integer?
 
Old 07-07-2005, 08:58 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
I suppose the advantage is that you can run a query and
get actual time & date out of it without a programatical
interface for data extraction. If via PHP is the only way
you'll ever be using the database integers should be just
fine... HIH


Cheers,
Tink

Last edited by Tinkster; 07-07-2005 at 09:05 PM.
 
Old 07-07-2005, 09:01 PM   #5
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Original Poster
Rep: Reputation: 121Reputation: 121
Thanks Tinkster. Yes. This database is specifically only for the PHP application.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help - My Samba share changes the timestamp when copying files to it.. Preserve Time. hheejj Linux - Software 2 06-28-2005 09:34 AM
sw to import some integer or floating point data and chart them tcma Linux - Software 1 11-04-2004 06:53 PM
mysql type question Hockeyfan Linux - Software 1 09-22-2004 10:20 PM
data type to hold pointers? SciYro Programming 5 05-15-2004 05:24 PM
Shell-Script check if $xx is of type integer d-fens Programming 5 07-11-2003 08:38 AM


All times are GMT -5. The time now is 10:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration