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")); Link to comment https://forums.phpfreaks.com/topic/91293-mktime-and-date-question/ 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); Link to comment https://forums.phpfreaks.com/topic/91293-mktime-and-date-question/#findComment-467873 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 Link to comment https://forums.phpfreaks.com/topic/91293-mktime-and-date-question/#findComment-467874 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 Link to comment https://forums.phpfreaks.com/topic/91293-mktime-and-date-question/#findComment-467878 Share on other sites More sharing options...
rxbanditboy1112 Posted February 15, 2008 Author Share Posted February 15, 2008 Awesome! Thanks :-D! Link to comment https://forums.phpfreaks.com/topic/91293-mktime-and-date-question/#findComment-467900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.