LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 09-06-2001, 11:00 PM   #1
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 438

Rep: Reputation: 30
Dates and Times in MySQL


I've got a table in mysql that has a few columns. I want one of the columns to record a date and time for each row that is put into the table. I've been trying DATETIME and TIMESTAMP but with no success. I've been referring to the mysql documentation. Any ideas?
 
Old 09-12-2001, 06:15 PM   #2
sykkn
Member
 
Registered: Apr 2001
Location: Texas
Distribution: Mandrake 8.0, RedHat 7.1
Posts: 48

Rep: Reputation: 15
Why not just have your script/program send the timestamp with the rest of the information?

You can set TIMESTAMP/DATETIME feild 'time = $timevar' along with the rest of the feild value pairs and you effectively have the time the row was added.

I did this with a php script I wrote to show visitors to my site and when they visited.

PHP Code:
<?
.......

$sqlquery "INSERT INTO $table
             (ip,referrer,search,url,date)
             VALUES('
$ip','$referrer','$search','$url','$datetime')";

........
?>
 
Old 09-13-2001, 03:27 AM   #3
glj
Member
 
Registered: Jul 2001
Location: London
Distribution: RH 9
Posts: 151

Rep: Reputation: 30
If you want timestamp to record the time the record was put in the table, or when the record is updated, just leave that field as NULL in the values(...) part of the statement.

glj
 
  


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
dumping mysql db script with dates markehb Linux - Software 2 04-23-2006 10:11 PM
Way to update mysql table 200+ times at once macie Programming 7 04-13-2005 11:45 PM
need to manipulate dates clsonnt Programming 5 08-19-2003 10:07 AM
php and mySQL dates before a sudden year go wrong??? Satriani Linux - Software 2 04-29-2003 03:13 AM
search for data in MySQL between two times. rhuser Programming 3 03-14-2003 12:32 AM

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

All times are GMT -5. The time now is 01:27 PM.

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