CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Format date in PHP

Print topic Send  topic

Author Message
skyhikeeper
Posted: 05/18/2005, 1:15 PM

I have a project where I connect to MSSQL database using PHP, however if I set the properties of the field to text the date displays as what it is when received from the query from the database, however when I set it to date teh information displayed on the field is blank. if i set the templates of the site to ASP, the result is perfect no problems, any way that I can resolve this.
DonB
Posted: 05/18/2005, 7:11 PM

Prior to mySQL 4.1, dates were formatted like 19991231015959 while
afterwards they were formatted like 1999-12-31- 01:59:59. I've found that
the date manipulation routines in the current PHP versions prefer the latter
format. I suppose that there was some similar cutover with PHP but I've not
run into a really old implementation of that to test with.

So, long story short, older mySQL and newer PHP makes dates misbehave. I
recently worked around this by using the following bit of code:

$changed = $db->f("changedate") ;
if (!strpos($changed, "-")) {
# Pre 4.1 timestamp, insert the required 'punctuation'
$changed = substr($changed,0,4) . '-' .
substr($changed,4,2) . '-' .
substr($changed,6,2) . ' ' .
substr($changed,8,2) . ':' .
substr($changed,10,2) . ':' .
substr($changed,12,2);

}

Maybe there's a more clever way, but this was quick and did what was needed
in my case.

--
DonB

http://www.gotodon.com/ccbth


"skyhikeeper" <skyhikeeper@forum.codecharge> wrote in message
news:5428ba25e35bba@news.codecharge.com...
> I have a project where I connect to MSSQL database using PHP, however if
I set
> the properties of the field to text the date displays as what it is when
> received from the query from the database, however when I set it to date
teh
> information displayed on the field is blank. if i set the templates of the
site
> to ASP, the result is perfect no problems, any way that I can resolve
this.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Nicole

Posts: 586
Posted: 05/19/2005, 2:35 AM

Hello,
Check my last response in the topic
http://forums.codecharge.com/posts.php?post_id=43243
I think it should help you

_________________
Regards,
Nicole
View profile  Send private message
skyhikeeper
Posted: 05/19/2005, 6:11 AM

Quote Nicole:
Hello,
Check my last response in the topic
http://forums.codecharge.com/posts.php?post_id=43243
I think it should help you


Hi Nicole

Have done that before , i just checked it agan and the result was exactly the same a blank date, I wonder if this could be influenced by the server been loaded with PHP5 and not PHP4,

Terence
Nicole

Posts: 586
Posted: 05/20/2005, 2:16 AM

I suppose that you used incorrect date format.
_________________
Regards,
Nicole
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.