Format Date in SPServices.SPDisplayRelatedInfo

Apr 7, 2011 at 12:05 AM

Hi,

I have two dates in my form that get displayed when using SPDisplayRelatedInfo and they get shown as "2011-03-25 00:00:00", which I'm not a fan of. The column name is called "WorkPlacementStart"

I'm not that confident in jQuery and have seen there are many date functions around but I can't find one that is suitable.

Can someone give me a hand to get the date into the format of dd/mm/yyyy? I'm guessing that this will go into the completefunc section but am not sure....

Thanks a lot.

p.s. this library is damn amazing, I'm using it so much, thanks for putting it together Marc.

Kevin (@23_kev)

Coordinator
Apr 7, 2011 at 3:20 AM
Kevin:

Glad you're having fun! The formatting you want to do will be with plain old JavaScript. Here's a page with some great examples:
http://www.webdevelopersnotes.com/tips/html/10_ways_to_format_time_and_date_using_javascript.php3

If you look at the output of SPShowRelatedInfo, you'll see that I give elements ids for easy selection. You can grab the value, reformat it, and replace the value with your formatted one. Check the docs for specifics about the ids.

M.
>