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 |
 |
 |
skyhikeeper
|
| Posted: 05/19/2005, 6:11 AM |
|
Quote Nicole:
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 |
 |
 |
|