Nightmareinhell Posted June 21, 2011 Share Posted June 21, 2011 Hello! This problem has been driving me insane. Ok so I am making a news article script that stores its information into a mysql database. My script for adding information seems to be working great, with one problem. The time() function returns a time that is a decade ahead (this is on a hostgator server also, they said they cannot do anything about it). So my question is, is there a way to subtract a decade off of it, or is there a different way to get the current time other than using the servers time? $future_date = time() - (3612 * 24 * 60 * 60); $today = date("d-m-y H:i:s", $future_date); The 3612 is the exact amount of days it is off including leap years. The odd thing is this actually adds a decade to it, so it used to be 6/11/2021, now it is 7/01/31. Thanks guys for any help!! Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/ Share on other sites More sharing options...
Alex Posted June 21, 2011 Share Posted June 21, 2011 That's really strange, both that the server time is off (and they won't change it) and that you're getting that result now. Are you sure it's still off by 10 years? Try this and tell us what output it gives back now: echo date("d-m-y H:i:s"); Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/#findComment-1233022 Share on other sites More sharing options...
Nightmareinhell Posted June 21, 2011 Author Share Posted June 21, 2011 It gives me back 6/11/2021 Lol, odd problem. I was thinking of contacting them again. They sent me to a link that said that they will not change the server time, but I would have assumed it would only have been off by times zones, not decades. Thanks for the response! Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/#findComment-1233025 Share on other sites More sharing options...
Alex Posted June 21, 2011 Share Posted June 21, 2011 Did you really run it again or just copy and paste the old result? That's not the formatting that should be returned at all. Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/#findComment-1233026 Share on other sites More sharing options...
Nightmareinhell Posted June 21, 2011 Author Share Posted June 21, 2011 I apologize as I ran it through my whole script into my database which returns it into a different format. Anyway, here is what I get. 21-06-11 20:49:59 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/#findComment-1233028 Share on other sites More sharing options...
Alex Posted June 21, 2011 Share Posted June 21, 2011 Well, that looks like the correct date. So the problem must be somewhere else and you haven't provided us with enough information to help. Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/#findComment-1233030 Share on other sites More sharing options...
Nightmareinhell Posted June 21, 2011 Author Share Posted June 21, 2011 Wow, I feel dumb now. just using the date function by itself, without the time() in there at all returns the correct time. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/240036-help-with-subtracting-years-from-the-time-function/#findComment-1233033 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.