ultrus Posted March 7, 2008 Share Posted March 7, 2008 Hello, It's Friday and I'm having a non-unctioning brain. Here's my challenge that will make me most greatful if you have any tips. I have a date range from a database that looks like this: $startDate = ""2008-03-11""; $endDate = ""2008-03-13""; For this to highlight days in my calendar, I need a resulting array of dates that look like this: $dates = array("03-11-2008","03-12-2008","03-13-2008"); Any clues on how to go from one format to the other? I'm off to get my mind off this for a sec, then come back and probably figure it out if I beat you to it. heh. Thank you in advance! Quote Link to comment Share on other sites More sharing options...
ultrus Posted March 7, 2008 Author Share Posted March 7, 2008 ah this might help as well: $startMonth = substr($startDate,5,2); $startDay = substr($startDate,8,2); $startYear = substr($startDate,0,4); $endMonth = substr($endDate,5,2); $endDay = substr($endDate,8,2); $endYear = substr($endDate,0,4); Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 7, 2008 Share Posted March 7, 2008 I'm probably way off... But again, it's Friday How about using explode on the "-" to get the three separate vars (y, m, d) then find the difference in days (psuedocoding this, because accounting for month spannning items would be long). Then loop through and add each date item to the array by concatenating the the variables back together with the incremented day. Or tell me I'm a goofball... Either way, I'm cool with it Good Luck Quote Link to comment Share on other sites More sharing options...
ultrus Posted March 7, 2008 Author Share Posted March 7, 2008 Hello MatthewJ, I just figured part of it out: $daysNum = floor((strtotime($endDate) - strtotime($startDate)) / 86400); MatthewJ is awarded: [most gratitude!] 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.