Jump to content

Help with subtracting years from the time() function


Nightmareinhell

Recommended Posts

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!!

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");

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.