|
I have tried playing around with different data-types, but nothings working.
I just want to save a date and time the 'TheDate' field in my database... heres what i've tried.
WITH A TIMESTAMP DATA TYPE
$datevar = time();
$sql="INSERT INTO Persons (TheDate)
VALUES
($datevar)";
but when I call it in it outputs all 0's
WITH A TIMESTAMP DATA TYPE
$datevar = time();
$sql="INSERT INTO Persons (TheDate)
VALUES
($datevar)";
and then when I'm calling it in i do the following (the $row because it's coming out in a table):
date("d-m-y h:i:s", $row['TheDate']
WITH A DATETIME DATA TYPE
$datevar = date("Y-m-d",time());
$sql="INSERT INTO Persons (TheDate)
VALUES
($datevar)";
but when I call it in it reads the -'s as minus signs and subtracts the month and day... (similarly with dividing the '/' signs) I've tried ALL sorts of combinations with the diff letters (ymdhis..etc) and everything... but sometimes it calculates and sometimes it says my query was invalid and that i should check my syntax (it says check the syntax before "" and tells me the last few digits of my time)
I've also tried to save with a varchar datatype
$datevar = ("d-m-y",time());
$sql="INSERT INTO Persons (TheDate)
VALUES
($datevar)";
but when it still doesn't work.
thanks in advance for all your help!
P.S for my own interest, when u save something as a timestamp database, and then u retrieve it and echo it, does it echo it as the actual time stamp (and u have to use the date() function to format it), or does it turn it into YYYY-MM-DD-HH:M:SS for you?
__________________
"If you say something interesting, people will remember your name" ~ Anonymous
Please login or register to view this content. Registration is FREE. asp <- Irony
|