How to format this date type 2010-06-24T00:00:00Z

2020-05-07 09:05发布

问题:

How to format this date type 2010-06-24T00:00:00Z to sun,24/06/10 7.15 p.m (CDT) using JavaScript or jQuery.?

sun,24/06/10 7.15 p.m (CDT) is just a format representation which I need and not the actual date of the above string.

回答1:

Pretty simple with JS -

var d_names = new Array("sun", "mon", "tue", "wed", "thu", "fri", "sat");
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
var curr_year = d.getFullYear();
document.write(d_names[curr_day] + ", " +curr_month + "/" + curr_date + "/" + curr_year);

and bob's your uncle...



回答2:

I recommend jQuery Globalization Plugin from Microsoft

http://weblogs.asp.net/scottgu/archive/2010/06/10/jquery-globalization-plugin-from-microsoft.aspx

example:

jQuery.format(new Date(1955,10,5), "dddd MMMM d, yyyy"); // Saturday November 5, 1955