You are here: Date formatting issue « All PHP « IT news, forums, messages
Date formatting issue

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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация