Issue with date() php version 5.3.24

I have a form with a date field that is using the type date/datetime; does not matter which, both stores the date as a unix timestamp.  The field for the date is int(11).  When I retrieve the timestamp from the database and pass it to date() I get a warning:

 

date() expects parameter 2 to be long, string given

 

For fun, I tried (int) and it changed the timestamp to a null value.  After doing several tests to figure what is going on, I have concluded that perhaps the php version on the test server was the issue and so I checked and found it was php 5.3.24.  Anyone know of any issues with php 5.3.24 and the date() function?

 

Geeks, making the world a better place
Quote · 23 Jun 2014

You're passing it wrong timestamp for sure, check what you're passing it as the second parameter, it has to be unix timestamp. Echo out the value of the timestamp you get from database, its probably converted to datetime.

so much to do....
Quote · 23 Jun 2014

 

You're passing it wrong timestamp for sure, check what you're passing it as the second parameter, it has to be unix timestamp. Echo out the value of the timestamp you get from database, its probably converted to datetime.

Did exactly that, value was 1403420400 (I also tried datetime instead of just date; time is not needed though).  When I placed that value into an online unix timestamp to date converter I got the correct date that was chosen with the date picker; so using that with date() should have generated the date.  Instead I get the error message stated about being a string.  Searches on the net showed others with the same problem but no solution.

Edit, perhaps when I retrieve it, it is being converted to a string.  However, why does (int) then result in a null value, not zero but null.

Geeks, making the world a better place
Quote · 23 Jun 2014

Prashank25, you were correct, I am passing a string to it.  I did a var_dump() and examined the date fields and they are strings.

["date"]=> string(10)

At least now I know the warning was accurate.

Geeks, making the world a better place
Quote · 23 Jun 2014

All is good, (int) is now working; timestamp converted to date, sun is shinning and the birds are singing.

Geeks, making the world a better place
Quote · 23 Jun 2014
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.