Jump to content

[SOLVED] Inserting date into mysql?


JP128

Recommended Posts

[quote author=JP128 link=topic=118934.msg486495#msg486495 date=1166335040]
ok, i thought that I had it solved... but I dont... When I pull the date from the database, and try to format it, it goes to like Dec 31, 1969 4:33:00 pm
[/quote]

Are you sure you've got a datetime field in the database and not just a time field? It sure looks like its only time.
Anyone know what? Use ALTER TABLE to change the field type.

[code]
ALTER TABLE tblname CHANGE `date` joined_date TIMESTAMP;
[/code]

PS; Date is a reserved word in mysql so you shouldn't really be using it as a filed name. The above query should change it to [i]joined_date[/i] as well as changing the data type.
[code]
$time = $row['joined_date'];
$newTime= date("m/d/Y h:i:s",$time); 

echo "Name: " . $row['firstname'] . " " . $row['lastname'] . "<br>";
echo "User: " . $row['username'] . "<br>";
echo "E-Mail: " . $row['email'] . "<br>";
echo "B-Day: " . $row['dob'] . "<br>";
echo "Status: " . $row['rank'] . "<br>";
echo "Date Joined: ". $newTime . "<br>";[/code]

it comes out like Date Joined: 12/31/1969 04:33:26
ALTER TABLE users CHANGE `date` joined_date TIMESTAMP;

mysql_query("insert into users values('','$firstname','$lastname','$email','$username',md5('$password'),'$dob','2',now())") or die(mysql_error());

        19 //ID
firstnametest //Firstname
lastnametest //Lastname
emailtest //email
usernametest //Username
81dc9bdb52d04dc20036dbd8313ed055 //MD5 Password
01-01-1900 //DoB
3 // Rank
2006-12-17 15:07:37 //Date Joined

Archived

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

×
×
  • Create New...

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.