I'm working on this now for something.
Personally I think it's a mistake to treat the dates as strings - first
convert them to dates, then your job will be easier.
It may be as simple as this:
var d=new Date("05/17/2005 01:33 AM")
If the string doesn't parse correctly (if JavaScript doesn't recognize the
date format) a regex could be used to convert it to a date format that
Javascript does recognize.
To actually deal with the objects I'm using my obCollectionOrdered
component. It's available here:
http://www.depressedpress.com/depressedpress/Content/Development/JavaScript/
Extensions/ObCollectionOrdered/Index.cfm
Once I have the dates I you could do a simple sort function and pass it to
the sort method. I actually create a new property of the date object
containing the value of Date.parse() (a numeric representation of the date).
I can then use the "SortByProp()" method of my collection component to sort
the dates (both ascending and descending). It's insanely simple after that
to display the dates (in any format you like) by looping over the
collection.
Works a treat.
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:157879
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54