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