If you're using ASP.NET AJAX already in your project, Dave Ward explains how to use ASP.NET AJAX extensions for this purpose in his blog post Work smarter: MS AJAX's JavScript type extensions:
Simplify formatting client side dates
with Date.format If you’ve spent much
time working with dates in JavaScript,
you know what a hassle it can
sometimes be. To greatly ease this,
ASP.NET AJAX extends the JavaScript
Date object with a formatting function
that closely mimics the ToString
formatting paradigm that we’ve been
using for years. Here are a few
examples:
var today = new Date('12/3/2007');
var shortDate = today.format('d');
// d formats the date as MM/dd/yyyy
// shortDate == '12/03/2007'
var longDate = today.format('D');
// D formats the date as dddd, dd MMMM yyyy
// longDate == 'Monday, 03 December 2007'
var customDate = today.format('MMMM, yyyy');
// Custom format string to format the date as MMMM, yyyy
// customDate == 'December, 2007'
Date.format accepts most of the
standard DateTime format strings, such
as d and D. If none of those suit your
needs, Date.format also provides
almost unlimited flexibility via
custom formatting strings. For a full
list of formatting string parameters,
see the Standard DateTime Format
Strings and Custom DateTime Format
Strings reference pages on MSDN.