peculiar date issue
Hey guys I have an interesting date issue.
I'm trying to store birthdays. The MYSQL column is set as INT(10) and the name of the column is bday.
I have 3 dropdowns: month, day, year.
I check that all the info is correct before I convert the data into timestamp for the database table.
So if my bday is: June 10 1990 it goes in as: 6, 10, 1990 respectively.
When I log off my site and come back, it seems to pull the data out with one day off, but the rest of the data is correct.
So I would get: 6 9 1990.
Here's the code when I pull it out of the DB:
This gives me again: 6 9 1990
It is just sooo very weird that the day is always one off.
But everything else, MONTH or YEAR goes in and out perfectly.
If I change the day to 25, then I get back 24...
Do you guys have any idea why it does this?
I kept the code pretty short because I think most of you could figure out what I'm doing, and I don't beleive there's much more that I really need to show you but if you need any more code, let me know...
Some more info.
I made my birthday: july 15 1978. Here is the mktime data that goes into the DB.
$bday = mktime(0, 0, 0, 7, 15, 1978);
$bday becomes: 269323200
Before DB INSERT
269323200 <-- mktime version of: 7 15 1978
I check the DB to make sure it has the same data and it does.
269323200 <--- Same as above
I then log off, and back on to pull the data out and make sure the data hasn't changed, and it has not.
269323200 <--- Same consistent data.
But when I use the date() function, it shows: 7 14 1978
$date = date("n j, Y ",$bday);
Hmmm I think I might be getting somewhere.
I changed my bday to July 1st 1978 to see what would happen.
The result is that upon logging in, it now shows June 31st 1978.
very very interesting...
Ok guys, I figured it out, it was a timzezone issue.
You see, up in my header file, I have this:
Because my server is located in Utah which is 2 hours behind.
Anyways, the LOGIN page doesn't call the header file just yet, so it was using the Utah server timestamp. Once I called the timezone_set function above in the login page itself, it is now correct.
very interesting, I was going to suggest maybe it was a leap year bug
lol, I would never know that. TBH I don't even know where my server is exactly...
Maybe it emigrated whilst you weren't looking. It realises you don't know and moves itself to a warmer climate every 6 months.
(grrrr char limit)
|All times are GMT. The time now is 01:06 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0