RE: [PHP] looong date formatting for MySQL

From: Date: Sat, 18 Aug 2001 00:25:21 +0000
Subject: RE: [PHP] looong date formatting for MySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63250@lists.php.net to get a copy of this message
<?php $a = date( "Y\-m\-d" ); print( "$a" ); ?> should do the job... there is lot's of things that you can incorporate in the date function... look it up at www.php.net/date -----Original Message----- From: CGI GUY [mailto:cgi_guy1313@yahoo.com] Sent: Friday, August 17, 2001 4:16 PM To: php-general@lists.php.net Subject: [PHP] looong date formatting for MySQL 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. Here's my code: <?php $today = getdate(); $year = $today['year']; $month = $today['mon']; $mday = $today['mday']; if ($month < 10) { // $month = join("0",$today['mon']); $month = "0"; $month .= $today['mon']; } $printtoday = $year; $printtoday .= "-"; $printtoday .= $month; $printtoday .= "-"; $printtoday .= $mday; print($printtoday); ?> It works, but sheesh... __________________________________________________ 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 (#63250) next »