Forum Moderators: open
But here is where the confusion kicks in and I'm so confused I'm not even sure how to go about asking it, so feel free to read between the lines:
What are the best practices for storing dates? Should they be stored with the user's local time? But then what if the posting client travels from east to west? Will that buy them 3 hours of posting time? The bigger concern is if the mySQL server is located in the east coast, and someone is trying to check on a job they posted in the west coast b4 a cuttoff date, their post might say it has expired (relative to the east) when in the west they actually should have 3 hours left. And that might frustrate them.
I might be totally missing something here and I am new to this. My brain hurts. Forgive me. Dates confuse me. I did ok with human dates, as I am married, but calendar dates, dang ... thanks in advance for the help!
PS: I have a feeling this text from the mySQL manual is key (that I use CURRENT_DATE as opposed to NOW), but alas, my peanut brain cannot currently decode it's techie jargon:
The CURRENT_TIMESTAMP(), CURRENT_TIME(), CURRENT_DATE(), and FROM_UNIXTIME() functions return values in the connection's current time zone, which is available as the value of the time_zone system variable. In addition, UNIX_TIMESTAMP() assumes that its argument is a datetime value in the current time zone.
So if you'd like to contrast NOW() and CURRENT_DATE(), feel free. Again, many thanks and lobster dinners to you!
When the query to pull the classifieds is run all that is needed is a simple addition to this time field, since it is an integer. You can then format the date however you please using date()
I only use the TimeStamp as integer for giving me a unique record locator to match against another table.
Dates are indeed confusing. You can'd do simple addition on dates because of the 30/31/28 day thing. mySQL has lots of date functions to add/subtract and extract date parts. It was difficult at first, but I grew to like it very much.
"The bigger concern is if the mySQL server is located in the east coast, and someone is trying to check on a job they posted in the west coast b4 a cuttoff date, their post might say it has expired (relative to the east) when in the west they actually should have 3 hours left."
PS: I see that webmasterworld stores the times as UTC and the displayed posting datetime (top right) definitely does not match with my current datetime here in Arizona. So maybe a better question is how does webmasterworld do it? Shall I follow the masters (sorry, that was a horrible pun)?