note 9994 deleted from function.getdate by jimw
| From: | jimw@php.net | Date: | Mon, 22 Oct 2001 23:40:43 +0000 |
| Subject: | note 9994 deleted from function.getdate by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-19298@lists.php.net to get a copy of this message | ||
<?php
There is a simple way to get getdate(); into the mySQL format:
Here is an function I define as "fixDate()"
function fixDate($int){
$int = ($int<10)?str_replace("0", "", $int):$int;
$int = ($int<10)?"0$int":$int;
return $int;
}
$d = getdate();
echo $d[year]."-".fixDate($d[mon])."-".fixDate($d[mday]);
If you want the time in addition to the date add this line:
echo "
".fixDate($d[hours]).":".fixDate($d[minutes]).":".fixDate($d[seconds]);
?>