|
Posted by Matt on 08/06/06 02:37
I am attempting to format date values returned from a database
// snippet of code
while ($myrow = mysql_fetch_array($result)) {
$offr_vsdate = $myrow[offr_vsdate];
//
If I echo the date 'as it comes'
echo $offer_vsdate;
I get the output: 2006-08-01
But if I try to format the date as follows
echo date("d/m/Y",$offer_vsdate);
I get the output: 01/01/1970
I get the same result when attempting to format any date returned from the
database.
I have tried the same formatting with the current date
echo date("d/m/Y");
and this works fine with the output: 06/08/2001
My conclusion is that I must be entering something other than a date serial
into the database, text possibly?. The field is 'date' data type and after
looking at the way the date value defaults, I have inserted the current date
as follows as a test.
$curr_date = date("Y-m-d");
This gives the same results though when I extract and attempt to format.
I use the mysql_real_escape_string construct in all my queries
What am I missing?
Any help gratefully received.
"I'm an idealist. I don't know where I'm going, but I'm on my way." - Carl
Sandburg
http://clicktowalk.com
Page design © Matthew McCabe - http://mattmadethis.com
Navigation:
[Reply to this message]
|