PC Nerd Posted December 13, 2007 Share Posted December 13, 2007 Hi, I wanted to create an array that contained every day until 2 months from $now. I then want to place this into a drop down box - which i wont have any trouble with. is there a date function that can do this for me? also - i wanted to create 3 drop down menues, Day, Hour(24), Minute. and from teh data pulled from these create a timestamp value. - I may also want to have 12 horu time with an AM or PM selection as well. How woudl i go about this? i am familiar with teh timestamps and time formatting: from timestamp to text, but i dont know how to go from text to timestamp. Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 13, 2007 Share Posted December 13, 2007 The strtotime() function will convert date/time strings to an integer. As for your question about every date until two months from now, you can do something like this: <?php $dates = array(); for($i=time();$i< strtotime('+2 months');$i += 86400) // 86400 is the number of seconds in a day $dates[] = $i; echo '<pre>' . print_r($dates,true) . '</pre>'; // dump the raw numbers foreach ($dates as $date) echo date('F j, Y',$date) . "<br>\n"; // format the dates ?> Ken Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted December 13, 2007 Author Share Posted December 13, 2007 thanks.... is it the same with hours and minutes? and if ive got the days, hours and minutes - how would i place the strings together..... ie if they trhee are seperate? thanks 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.