RE: [PHP] looong date formatting for MySQL

From: Date: Sat, 18 Aug 2001 04:13:05 +0000
Subject: RE: [PHP] looong date formatting for MySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63267@lists.php.net to get a copy of this message
Still, read this php.net/date it has a variety of functions, dates with zeros and without... Another thing you can do is using the mySQL manual. Did you know that mySQL has a WHOLE BUNCH of date functions? Cheers, Maxim Maletsky -----Original Message----- From: CGI GUY [mailto:cgi_guy1313@yahoo.com] Sent: Saturday, August 18, 2001 8:30 AM To: php-general@lists.php.net Subject: Re: [PHP] looong date formatting for MySQL Thanks for the reply, however, that function call doesn't zero-substitute (i.e., "07" for "7", "03" for "3", etc.); that's why I've added this: if ($month < 10) { $month = "0"; $month .= $today['mon']; } By default, MySQL only accepts dates as YYYY-MM-DD; PHP's getdate(Y-m-d) prints out YYYY-M-DD or YYYY-MM-DD IF AND ONLY IF the month is two-digit. --- Adam Rambousek <rambousek@volny.cz> wrote: > date("Y-m-d") should do the job > > > There's gotta be an easier way to get create a > date > > properly formatted for MySQL's standard YYYY-MM-DD > > DATE field format. Any suggestions, > > smacks-upside-the-head, etc. on how to reduce this > > would be greatly appreciated. > > > > -- > Adam Rambousek > email: rambousek@volny.cz ICQ: 47596279 > Jabber: rambousek@njs.netlab.cz > www: http://adamovy.cestiny.cz > http://hemzeni.poda.cz/matrix > * I'll save you from yourself, From those demons of > the night > They promise fame and fortune, All that you > eagerly desire. - Era > > > -- > 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 > __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- 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 (#63267) next »