I have a database that has got a Time field with datatype timestamp(14)
but if I try to do sth like:
insert into ChatUsers_tbl values('NULL', 'Raghavan', '".time()."');
time() is of 10 digits but doesnot get into the mysql database which is of 14 digits.
Instead when I insert I get 'fourteen zeros' in the field.
What is the best way to store a timestamp?
clarification: time() in PHP
Moderator: General Moderators
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
Might want to read http://dev.mysql.com/doc/mysql/en/datetime.html
I believe http://adodb.sf.net has a class dedicated to time handling...
Code: Select all
// using MySQL current timestamp
$query = "INSERT INTO foo VALUES (NOW());";
// using PHP current timestamp
$query = "INSERT INTO foo VALUES (FROM_UNIXTIME(" . time() . "))";- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
I was trying something like this but it still thinks it as wrong format
I have got the field with timestamp(14) in Mysql.
ex output: 20050809164830(14 digits)
1. What do you think is the problem now?
2. The only difference btw DateTime and Timestamp in mysql is the former one has got separators btw each part...is it true?
the later has got no separators btw any of the parts?
I am actually looking for time and date in a field and it could be sorted.
I have got the field with timestamp(14) in Mysql.
Code: Select all
echo "<br />".date(YmdGis);1. What do you think is the problem now?
2. The only difference btw DateTime and Timestamp in mysql is the former one has got separators btw each part...is it true?
the later has got no separators btw any of the parts?
I am actually looking for time and date in a field and it could be sorted.