Jump to content
Larry Ullman's Book Forums

Dates Treated Differently On Local And Remote Servers


Recommended Posts

I was perplexed why the same script yielded different results on my local and remote servers:

 

In a mySql database (locally) I have "0000-00-00" in the Date column (formatted as a date).

I have the same thing in my remote server.

 

A select statement for retrieved the value of the 'paid thru' column for a member whom has never made a dues payment has always been set to "0000-00-00" by design.

 

strtotime ($paid_thru) would therefor yield a gigantic negative number on my local server and serve the purpose for the conditional:

 

if (strtotime ($paid_thru) <0) { ....}

 

The same thing on the remote server yields no value at all and stopped all the gears.

 

After several head-scratching minutes, I decided to change the "0000-00-00" scheme to the arbitrary date of 1969-06-06 ( a great year as some of us recall -Larry?). Discovering the db concept of "The Epoch" year, 1970-01-01, -which, as far as sql servers is concerned, is the beginning of the universe- 1969 was a time before time actually existed and therefore yielded a negative value instead of nothing from the remote. Because no member would never have gotten this far without paying their dues since "the summer of love" without getting the boot, this will work.

 

But my actual question:

I'm guessing that my version of PHP or MYSQL is earlier than that on the remote server. But which one? Does mySQL no longer treat 0000-00-00 like a date (though it still allows it in a date formatted column" or does the 'strtotime' php function no longer do the math on it as it used to?

 

p.s. If I echo $paid_thru, it prints out 0000-00-00 on both servers and this was what was throwing me.

(so maybe it's the php version?)

Link to comment
Share on other sites

Thank you. I guess even though "000-00-00" was echoed out on both local and remote servers, the actual value of the two must be different. Else the strtotime() should have worked on both of them.

Link to comment
Share on other sites

 Share

×
×
  • Create New...