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 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 <[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 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: [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]

Reply via email to