Fri 26 Mar 2004 08:43:50 PM UTC, original submission:
The function works like this, and returns the new formatted date:
convertDate($date, $dateFormat, $newFormat)
The function does this by finding the seperator used to seperate month, day, and year. Then builds an array of the month day values, and maps each value to the d/m/y format of the date passed.
For Example: Array ( [d] => 26 [m] => 03 [Y] => 2005 )
Then it finds the seperator of the format that you want the date to output the date to. Then builds an array of the month/day/year new format
And ultimately builds the new formmated date by starting from the order of the desired format, and matching the first value key with the old formmated value key.
An Example of what would make it not work:
convertDate('30-Mar-2004', 'd-M-Y', 'm-d-Y')
The passed date, turns into this:
For Example: Array ( [d] => 30 [M] => Mar [Y] => 2004 )
Notice how month is formmated as 'M' in the old format, and 'm' in the new format. At the end of the function when its building the end array that puts the old formmated date into the new formmated date, it looks for the 'm', but it cant find it, and returns a blank.
So the outcome will be: /30/2004
d-M-Y is the only dateformat Preference that is different than the rest because it has the 'M' instead of 'm'.
I am not sure what the best way to fix this is, but thought I would explain what is happening.
- scibe
|