rxbanditboy1112 Posted February 15, 2008 Share Posted February 15, 2008 I would like to know if in the following line of code if the line would always give me 4 hours ago. My biggest concern is when it becomes midnight of the next day... Will it still give me 4 hours ago or will it give me the next day then subtract four hours from the hour. $today = strtotime(mktime(date("G")-4,date("i"),date("s"),date("n"),date("d"),date("Y")); Quote Link to comment Share on other sites More sharing options...
nogray Posted February 15, 2008 Share Posted February 15, 2008 time() will return the number of seconds, so you can easily subtract 4 hours (in seconds) to get 4 hours ago $today = time() - (4*60*60); Quote Link to comment Share on other sites More sharing options...
rxbanditboy1112 Posted February 15, 2008 Author Share Posted February 15, 2008 but i need a full date, not only the time. Thanks for the help :-D Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 15, 2008 Share Posted February 15, 2008 what you do wit the timestamp is up to you, you just need the value of X seconds from epoch that is 4 hours from current time i.e <?php echo date("y-m-d", time()-(4*60*60)); ?> Should do it for you also <?php echo date("y-m-d", strtotime("-4 hours",time()); ?> should also work as well Quote Link to comment Share on other sites More sharing options...
rxbanditboy1112 Posted February 15, 2008 Author Share Posted February 15, 2008 Awesome! Thanks :-D! Quote Link to comment 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.