LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Cheers,
Tink
 
Old 07-07-2005, 08:52 PM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:47 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration