display formatted date??
| From: | r_ramkumar at 123india dot com | Date: | Mon, 26 Jun 2000 11:44:34 +0000 |
| Subject: | display formatted date?? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-3101@lists.php.net to get a copy of this message | ||
hi,
i have a field "dated" of type DATETIME. now how to i format this into the format
(dd-mon-yyyy). i tried the following code but i am not getting the reqd result
it always gives 01-Jan-1970.
code....
<? $row = mysql_fetch_array($result) ?>
<tr><td valign=top><font color="#3300CC" size="2">
<? $temp=$row["dated"];
echo "value in MySQL = $temp";
$arr1 = getdate($temp);
foreach ($arr1 as $key => $value) {
echo "<br>Key: $key; Value: $value\n";
}
echo "<br>strft = " . strftime("%d-%b-%Y",$temp);
echo "<br> date('d-M-Y') = " . date("d-M-Y",$temp);
?>
</font> </td>
</tr>
result i get ...
value in MySQL = 2000-06-23 11:00:22
Key: seconds; Value: 20
Key: minutes; Value: 3
Key: hours; Value: 6
Key: mday; Value: 1
Key: wday; Value: 4
Key: mon; Value: 1
Key: year; Value: 1970
Key: yday; Value: 0
Key: weekday; Value: Thursday
Key: month; Value: January
Key: 0; Value: 2000
strft = 01-Jan-1970
date('d-M-Y') = 01-Jan-1970
thanks
______________________________________________________
123India.com - India's Premier Portal
Get your Free Email Account at http://www.123india.com