looong date formatting for MySQL
| From: | CGI GUY | Date: | Fri, 17 Aug 2001 23:16:17 +0000 |
| Subject: | looong date formatting for MySQL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-63245@lists.php.net to get a copy of this message | ||
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/