yarub Posted May 5, 2008 Share Posted May 5, 2008 What's the easiest way to figure out the time() for a date infront of you. Today is Monday. What's the easiest way to go about getting the time() for Saturday? An array or query or whatever that would work for any day of the week to figure out when Saturday is. Quote Link to comment Share on other sites More sharing options...
marcusfaye87 Posted May 5, 2008 Share Posted May 5, 2008 If today is monday may 5th $time = time() + (5 * 24 * 60 * 60); // 5 days; 24 hours; 60 mins; 60sec echo date ("d-m-Y", $time); you add 5 days to the current time. does that help you? Quote Link to comment Share on other sites More sharing options...
yarub Posted May 5, 2008 Author Share Posted May 5, 2008 Not really. =\ I want it to automatically find it for any day. So if it's Thursday, I want it to know that Saturday is only two days away. If it's Sunday, I want it to know that Saturday is six days away. Quote Link to comment Share on other sites More sharing options...
marcusfaye87 Posted May 5, 2008 Share Posted May 5, 2008 $day = date ('N'); // day in numbers 1 - 7 if ($day == 7) { $daysLeft = 7; } else { $daysLeft = 6 - $day; } $time = time() + ($daysLeft * 24 * 60 * 60); // x days; 24 hours; 60 mins; 60sec echo date ("d-m-Y", $time); this should help then Quote Link to comment Share on other sites More sharing options...
yarub Posted May 5, 2008 Author Share Posted May 5, 2008 Thank you! =D Quote Link to comment Share on other sites More sharing options...
marcusfaye87 Posted May 5, 2008 Share Posted May 5, 2008 sorry made an error, I changed it but... if ($day == 7) { $daysLeft = 7; } else { $daysLeft = 6 - $day; } it was 8 before, but it doesn't take 8 days to get from sunday to saturday. and I forgot to put a double "=" (I'm not good at programming on a forum. phpDesigner FTW! Also, I would recommend you check php.net first before you post here, there's a lot there that can help you The whole fun of programming lies in solving your problems (well that's what I think), not in just getting the code presented Quote Link to comment Share on other sites More sharing options...
yarub Posted May 5, 2008 Author Share Posted May 5, 2008 Yeah- I tried looking there. I just didn't know how to phrase my search to get what I wanted. Quote Link to comment Share on other sites More sharing options...
marcusfaye87 Posted May 5, 2008 Share Posted May 5, 2008 just go to www.php.net and type "date" in the functions field, then hit return and be amazed? 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.