Skip to main content
Known Participant
March 18, 2012
Question

php long error

  • March 18, 2012
  • 1 reply
  • 944 views

I have the following code and input, and am getting this error:

code:

$date = date('D, d M Y H:i:s', $date);

input:

1332092255

error:

Warning:  date() expects parameter 2 to be long, string given in (page) on line 72

This topic has been closed for replies.

1 reply

Participating Frequently
March 19, 2012

What is the value in $date before calling the date() function? Where is it coming from? Is it a string or int?

Known Participant
March 19, 2012

the value is 1332092255.  it comes from mysql database.  i have it listed as varchar there.  not sure that that should affect it though. 

Participating Frequently
March 19, 2012

The PHP reference manual lists the argument as an int, so storing it as a varchar would defintely cause a problem in that regard. However, the error message is confusing, making it sound like it would accept a string value. I'm not sure how to interpret that.  Why are you storing it as a varchar in the first place? It's a numeric value and should be stored as such. For a quick test, try casting it as an int

$date = date('D, d M Y H:i:s', (int)$date);