2 Replies - 239 Views - Last Post: 01 November 2013 - 02:02 AM Rate Topic: -----

#1 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Wrong conversion of numerical date to text

Posted 31 October 2013 - 08:36 PM

Hi!!!
I have saved a date in the database and its format there is in 2013-11-01..
and i need to get the date and reflect it in the interface...but it reflects what is stored in the database...

so i search on google how to convert numerical date to text... and i followed it... yes it converts into text but it converts the wrong date...

$result_requestremarks = pg_fetch_array($sql_requestremarks, NULL, PGSQL_ASSOC);
			$dr = $result_requestremarks['date_requested'];
echo date('F d Y', $dr);


i showed there the actual fetching of the data... and i dont have any problems in it..
the date in the date in the database is -- 2013-10-24
and it converts it into -- January 01 1970..

how come does it become a 1970???? its clearly 2013...
i had so much trouble in this...

ANY HELP WILL BE APPRECIATED...

Is This A Good Question/Topic? 0
  • +

Replies To: Wrong conversion of numerical date to text

#2 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: Wrong conversion of numerical date to text

Posted 31 October 2013 - 11:36 PM

What database engine are you using, and what is the data type of the "date_requested" field in the table?
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,227
  • Joined: 08-June 10

Re: Wrong conversion of numerical date to text

Posted 01 November 2013 - 02:02 AM

PostgreSQL has a bulk of functions to format dates already in the query. so you donít need to do that in PHP.

Quote

how come does it become a 1970????

unparsable date date() expectrs a UNIX-timestamp, not da date string, hence you get the result like you were calling date('F d Y', 0)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1