Page 1 of 1

date fetching problem

Posted: Tue Oct 05, 2010 1:31 am
by faizpayi
Hii....i am plannning to implement a portal using php.I am using ms sql server 2008 as the database and hosting it with IIS 6.I am facing problem for the following


-I am trying to grab a date value from the database and echoing it.I tried using " $empdoj =date("d/m/Y", strtotime($row['emp_doj']));"($emp_doj is the sqlserver attribute) but it is showing 01/01/1970 always.

Thanks for the help in advance..

Re: date fetching problem

Posted: Tue Oct 05, 2010 1:46 am
by amargharat
please check what value $row['emp_doj'] gets you

Re: date fetching problem

Posted: Tue Oct 05, 2010 1:48 am
by faizpayi
actually the value of emp_doj is 2010/05/31 but the output of the code returns 01/01/1970

Re: date fetching problem

Posted: Tue Oct 05, 2010 4:38 am
by amargharat
Your code is fine and checked with given value.

Just verify $row['emp_doj'] whether it returns a correct date or empty

Re: date fetching problem

Posted: Tue Oct 05, 2010 9:53 am
by faizpayi
Hi thanks for the help.The value of the variable was correct but it was only returning one value.Luckily I tried $empdor=sqlsrv_get_field( $stmt,8,SQLSRV_PHPTYPE_STRING( SQLSRV_ENC_CHAR)); it worked.

Thanks

Faiz