Re: RE: How to insert time and date into mysql?

From: Date: Thu, 01 Mar 2001 14:57:32 +0000
Subject: Re: RE: How to insert time and date into mysql?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-42175@lists.php.net to get a copy of this message
Why not use the CURDATE() and CURTIME() functions built into mysql? Kevin Cawthorne ----- Original Message ----- From: "Foley, John" <John.Foley@pollak.com> To: "'Zenith'" <zenith@linuxmail.org>; <php-general@lists.php.net> Sent: Thursday, March 01, 2001 2:20 PM Subject: [PHP] RE: How to insert time and date into mysql? > > I have an application that serializes uploaded files by datetime of > upload. > This may not be the most efficient, but this will yield a MySQL > DATETIME type string: > $datetime = date("YmdHis"); > > If you are looking for a DATE column and a TIME column seperately > (not recomended . . . use logic to parse the TIME and DATE parts of a > DATETIME column) thet you will need to use > $myDate = date("Ymd"); file://year,month,day with preceeding zeros > $myTime = date("His"); file://hours,minutes,seconds with preceeding > zeros > I have not checked the documentation for these: check the DATE and > TIME column type requirements in MySQL, and the date() function in PHP. > > > Obviously, make sure your MySQL column data type is DATETIME, and > that you single quote the $datetime value since it's considered text. Here > is my SQL string: > $sql="INSERT INTO $docMaster ( > sqDocID, > sqUID, > sqSubmitDate, > sqDocAnon, > sqRequestID, > sqHostID, > sqTitle, > sqCopies, > sqOptionStr, > sqFileName, > sqDocType, > Fsize, > ppFsize > ) > VALUES ( > NULL, > $uid, > '$datetime', > '$Anon', > '$request_id', > $sqHostID, > '$title', > $copies, > '$option_list', > '$file', > '$DocType', > $Fsize, > $tmpFsize > )"; > > > It should be obvious by now that I am making a PHP4/CGI shell script > LP print filter. > This filter intercepts incoming print streams, then converts > postscript to PDF or compresses PCL, moves the result to a controlled > directory structure, and then logs to database. > A little Apache with PHP with MySQL later, and I have a hands-off > paperless queueing system. I love OpenSource! > > Any interest from the PHP community in seeing this effort released? > I'm developing on Solaris for production use on Solaris, and have noted some > incompatabilities with Linux, FWIW. > > > > John T. Foley > Network Administrator > Pollak Engineered Products, Actuator Products Division, A Stoneridge > Company > 195 Freeport Street, Boston MA 02122 > ph: (617) 474-7266 fax: (617) 282-9058 > > The geographical center of Boston is in Roxbury. Due north of > the center we find the South End. This is not to be confused with South > Boston which lies directly east from the South End. North of the South > End is East Boston and southwest of East Boston is the North End. > > > > > > > > > -----Original Message----- > > From: Zenith [SMTP:zenith@linuxmail.org] > > Sent: Monday, February 28, 2000 1:16 PM > > To: php-general@lists.php.net > > Subject: How to insert time and date into mysql? > > > > How can I insert time and date into mysql table, > > if the table i have to insert has a field of type time, and a field of > > type > > date. > > > > Then how can I insert it in PHP, if I use time() function?? > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#42175) next »