Jump to content

converting "2008-03-11", "2008-03-13" to array("03-11-2008","03-12-2008","03-...


ultrus

Recommended Posts

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!  :)

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);

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.