Question

I'm loading variables from an SQL query, one of which is a unix timestamp. I'm using the PHP date() function to determine the day of the week. It seems to work fine, but I noticed that when the unix timestamp is NULL, the use of date("w", $myunixtime) yields a value of 3. I'm echoing the value of the timestamp, and I get a 'blank' as I should. Then right after that, I'm echoing the value of the function, and I see the 3. This is weird, and I don't see any documentation that explains this.

I'm on a Linux server using PHP Version 5.3.10. The server is in the Eastern Time Zone, and no, I'm not using UTC and don't want to -- way too much code to change for that. This shouldn't have anything to do with that anyway.

Has anyone else noticed weird values from the date() function -- when using recent years and not the 1599-1600 year issue that you may have noticed?

Was it helpful?

Solution

Your empty string casted to int as 0 and timestamp of 0 is begin of unix epoch, January 1 1970 00:00:00 GMT it was a Thursday but because your timezone it UTC -4 you get a previous day — Wednesday.

Anyway what result do you expect?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top