date fetching problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
faizpayi
Forum Newbie
Posts: 14
Joined: Tue Oct 05, 2010 1:24 am

date fetching problem

Post 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..
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: date fetching problem

Post by amargharat »

please check what value $row['emp_doj'] gets you
faizpayi
Forum Newbie
Posts: 14
Joined: Tue Oct 05, 2010 1:24 am

Re: date fetching problem

Post by faizpayi »

actually the value of emp_doj is 2010/05/31 but the output of the code returns 01/01/1970
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: date fetching problem

Post by amargharat »

Your code is fine and checked with given value.

Just verify $row['emp_doj'] whether it returns a correct date or empty
faizpayi
Forum Newbie
Posts: 14
Joined: Tue Oct 05, 2010 1:24 am

Re: date fetching problem

Post 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
Post Reply