How to split the below date format into day date and time.
Date Format is like "2013-05-07T11:04:00+05:30"
I want to display above date like "Tue,7 May 2013, 11.04AM".
Please suggest how to do this in java script or jquery
Thanks in Advance.
How to split the below date format into day date and time.
Date Format is like "2013-05-07T11:04:00+05:30"
I want to display above date like "Tue,7 May 2013, 11.04AM".
Please suggest how to do this in java script or jquery
Thanks in Advance.
You can use this very useful little library:
Example:
moment("2013-05-07T11:04:00+05:30", "MMMM Do YYYY, h:mm:ss a");
You might be able to use Date.parse(string), but there is no way to determine what date/time formats a particular JavaScript implementation supports.
Otherwise:
Number and then pass to the Date constructor taking separate components.Date.parse(), however others may or may not support this feature (such as IE<=8). For actually formatting the string, using a custom function is recommended, as the native Date methods are implementation dependent in their formatting of dates.You should work with the native Date Object - this is the easiest way to handle the string.
You can do the following:
var date = new Date("2013-05-07T11:04:00+05:30");
now you have several Date methods you can use to format your string and get the information you need, e.g. what you want is:
date.toUTCString()
// output:
"Tue, 07 May 2013 05:34:00 GMT"
You also could use a regex or an external library, but probably the best way (imo!) is to simply work with the Date Object.