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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.