| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

10-19-08, 13:46
|
|
Registered User
|
|
Join Date: May 2007
Posts: 139
|
|
|
to insert DATE TO DB/TABLE, how must inserted the date , what format ?
|
|
When in phpMyAdmin I have
Field Type
dateplaced timestamp
then in a command like
Code:
$datenow = time();
// $datenow = date("H:i j/m/y", $tsnow); // p.516-7
$status="PENDING";
$email6=$_SESSION['email'];
$query = "INSERT INTO $BookingsTable VALUES(NULL,'$datenow',0,'$email6','$status','$datep','$dated','$Locationp','$Locationd','$days','$mostdaysrate','$vat','$off','$finalprice','$cat')";
to insert DATE TO DB/TABLE, how must inserted the date , what format ?
I insert timestamp but appears(in BROWSE DATA  ELECT * FROM `bookings2` LIMIT 0 , 30)
0000-00-00 00:00:00 as field dateplaced ??? well, why appear zeros ?
|
|

10-19-08, 14:49
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
Im confused here
..do you men PHPMyAdmin or PHP
timestamp is a reserved word
you only need to encapsulate text / string columns
usually dates should be in ISO format (yyyy/mm/dd @ hh:mm:ss)
the @ hh:mm:ss is optional
http://www.google.co.uk/search?hl=en...e+Search&meta=
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

10-19-08, 15:13
|
|
Registered User
|
|
Join Date: May 2007
Posts: 139
|
|
|
|
I mean PHPMyAdmin.
Field = dateplaced // [1] '$datenow'
Type = timestamp
I try insert number $datenow = time(); to second column, that i guest is a big number, but appears when i browse data as 0000-00-00 00:00:00 and NOT today's date , well ?
|
|

10-19-08, 15:32
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
this
Code:
$datenow = time();
// $datenow = date("H:i j/m/y", $tsnow); // p.516-7
$status="PENDING";
$email6=$_SESSION['email'];
$query = "INSERT INTO $BookingsTable VALUES(NULL,'$datenow',0,'$email6','$status','$datep','$dated','$Locationp','$Locationd','$days','$mostdaysrate','$vat','$off','$finalprice','$cat')";
looks like PHP to me. Im not aware you can run scripts like that in PHPMyAdmin
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

10-19-08, 21:16
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
the format for mysql is 'yyyy-mm-dd hh:mm:ss' -- no @ 
|
|

10-20-08, 00:46
|
|
Registered User
|
|
Join Date: May 2007
Posts: 139
|
|
Please note: I want to keep track date/time , placed the booking, pickup date(car rent) and, dropoff date...I set these all fields to timestamp ... to save a date in db/table how I must insert date in what format(a big number) ? or what ?
If I insert a big number to timestamp field this will show a date like
'yyyy-mm-dd hh:mm:ss'
in the table: "browse command" in phpmyadmin(mysql) ?
|
|

10-20-08, 00:50
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
please do a SHOW CREATE TABLE for your table
|
|

10-20-08, 02:40
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
timestamp is a variant of datetime.. its set whenever the row is added or changed. so if you try to assign a value to a time stamp column you may have problems. if you have multiple timestamp columns they should all be set to the same value
use datetime datatype in place
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

10-22-08, 13:27
|
|
Registered User
|
|
Join Date: May 2007
Posts: 139
|
|
I try insert number $datenow = time(); to second column, that i guest is a big number, but appears when i browse data as 0000-00-00 00:00:00 and NOT today's date , well ?
0000-00-00 00:00:00 == A timestamp field to appear this what must be inserted ?
in my case I want to use time/date and compare it, appear only not expired bookings, sort by date etc ,... what to use ? what field type to use ?
|
|

10-22-08, 13:31
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
use DATETIME datatype
make sure you insert an actual datetime value, not a unix integer
|
|

10-25-08, 15:40
|
|
Registered User
|
|
Join Date: May 2007
Posts: 139
|
|
WHEN I take current time from
$datenow = time();
how insert in DATETIME datatype ?
|
|

10-25-08, 16:12
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
$DATENOW = format("Y-m-d H:i:s"); //FORMAT THE DATE IN MySQL form
$SQL = "Insert into mytable (my, column, list, mydatecolumn) values (my, values, list, $DATENOW);";
$sqlr=@mysql_query($SQL,$cnn) or die (echo ("myerrormessage".mysql_error());
$cnn is the variable containing a valid MySQL connection
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|

10-25-08, 16:47
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
|
|
why generate the value in php and pass it to the database?
why not use the database function?
so instead of this --
$DATENOW = format("Y-m-d H:i:s"); //FORMAT THE DATE IN MySQL form
$SQL = "Insert into mytable (my, column, list, mydatecolumn) values (my, values, list, $DATENOW);";
you would run only this --
$SQL = "Insert into mytable (my, column, list, mydatecolumn) values (my, values, list, CURRENT_TIMESTAMP);";
|
|

10-26-08, 11:17
|
|
Registered User
|
|
Join Date: May 2007
Posts: 139
|
|
DB field type: timestamp, HOW IS BEING SAVED AND APPEARED ? SAVED AS BIG INT ?
|
|

10-26-08, 11:28
|
|
Jaded Developer
|
|
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
|
|
what does it matter how it is stored.. its a variant of a datetime column, one you cannot set yourself. think of it as a read only date time.
it gets changed every time there are changes applied to that row.
there are functions to manipulate that datatype both in MySQL and PHP.
http://bugs.mysql.com/bug.php?id=24895
it looks lke the datetime datatype is an 8 byte value, I'd expect it to be an integer being he number of clicks since an arbitary date (probably the Unix Epoch). you shouldn't be any direct mathmatical manipulation on any date time values, use the presupplied functions.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|