[PHP] looong date formatting for MySQL
There's gotta be an easier way to get create a date properly formatted for MySQL's standard -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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] looong date formatting for MySQL
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 -MM-DD DATE field format. Any suggestions, smacks-upside-the-head, etc. on how to reduce this would be greatly appreciated. -- Adam Rambousek email: [EMAIL PROTECTED] ICQ: 47596279 Jabber: [EMAIL PROTECTED] www: http://adamovy.cestiny.czhttp://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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] looong date formatting for MySQL
?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:[EMAIL PROTECTED]] Sent: Friday, August 17, 2001 4:16 PM To: [EMAIL PROTECTED] 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 -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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] looong date formatting for MySQL
NOW() Jerry Lake Interface Engineering Technician -Original Message- From: Adam Rambousek [mailto:[EMAIL PROTECTED]] Sent: Friday, August 17, 2001 4:20 PM To: CGI GUY; [EMAIL PROTECTED] Subject: Re: [PHP] looong date formatting for MySQL 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 -MM-DD DATE field format. Any suggestions, smacks-upside-the-head, etc. on how to reduce this would be greatly appreciated. -- Adam Rambousek email: [EMAIL PROTECTED] ICQ: 47596279 Jabber: [EMAIL PROTECTED] www: http://adamovy.cestiny.czhttp://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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
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 -MM-DD; PHP's getdate(Y-m-d) prints out -M-DD or -MM-DD IF AND ONLY IF the month is two-digit. --- Adam Rambousek [EMAIL PROTECTED] 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 -MM-DD DATE field format. Any suggestions, smacks-upside-the-head, etc. on how to reduce this would be greatly appreciated. -- Adam Rambousek email: [EMAIL PROTECTED] ICQ: 47596279 Jabber: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] looong date formatting for MySQL
(regarding my previous post) although, it probably doesn't apply to what your doing. Jerry Lake Interface Engineering Technician -Original Message- From: Jerry Lake [mailto:[EMAIL PROTECTED]] Sent: Friday, August 17, 2001 4:28 PM To: [EMAIL PROTECTED] Subject: RE: [PHP] looong date formatting for MySQL NOW() Jerry Lake Interface Engineering Technician -Original Message- From: Adam Rambousek [mailto:[EMAIL PROTECTED]] Sent: Friday, August 17, 2001 4:20 PM To: CGI GUY; [EMAIL PROTECTED] Subject: Re: [PHP] looong date formatting for MySQL 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 -MM-DD DATE field format. Any suggestions, smacks-upside-the-head, etc. on how to reduce this would be greatly appreciated. -- Adam Rambousek email: [EMAIL PROTECTED] ICQ: 47596279 Jabber: [EMAIL PROTECTED] www: http://adamovy.cestiny.czhttp://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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re[2]: [PHP] looong date formatting for MySQL
look into the docs, there's possibility to display zeros (but I don't remeber exact letter) 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: -- Adam Rambousek email: [EMAIL PROTECTED] ICQ: 47596279 Jabber: [EMAIL PROTECTED] www: http://adamovy.cestiny.czhttp://hemzeni.poda.cz/matrix * Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] looong date formatting for MySQL
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:[EMAIL PROTECTED]] Sent: Saturday, August 18, 2001 8:30 AM To: [EMAIL PROTECTED] 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 -MM-DD; PHP's getdate(Y-m-d) prints out -M-DD or -MM-DD IF AND ONLY IF the month is two-digit. --- Adam Rambousek [EMAIL PROTECTED] 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 -MM-DD DATE field format. Any suggestions, smacks-upside-the-head, etc. on how to reduce this would be greatly appreciated. -- Adam Rambousek email: [EMAIL PROTECTED] ICQ: 47596279 Jabber: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]