Reputation: 11
This is the Json data I receive from service part.
"session":
{
"startTime": "08:00:00", // <--
"sessionId": 231,
"endTime": "09:00:00", // <--
"eventId": 100,
"maxSeats": 0,
"maxWaitlisted": 0,
"modifiedUser": "TestUser",
"modifiedDate": "2010-12-07", // <--
"sessionDate": "2010-12-01", // <--
"numberOfAttendees": 0,
"sessionName": "SessionName1",
"sessionStatusCode": "Open",
"cancelledInd": "No",
"cancellationEmailText": "Not",
"seatsRegistered": 0,
"seatsWaitlisted": 0,
"user_id": null,
"updateFlag": "R"
}
Using jquery I need to display "2010-12-01"
in "Wed, Dec 01"
Format in my HTML. Appreciate the Help
Upvotes: 0
Views: 227
Reputation: 655
You can convert the convert the value of "sessionDate" to a Date object, then get the weekday from the Date object, no jQuery needed.:
var sessionDate_to_printDate = function(sessionDate) {
var weekdays = new Array(
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
var months = new Array(
"Jan", "Feb", "Mar", "Apr", "Jun", "Jul", "Aug", "Oct", "Nov", "Dec");
var dateObj = new Date( Date.parse(sessionDate) );
return weekdays[dateObj.getDay()] + ", "
+ months[dateObj.getMonth()] + " "
+ dateObj.getDate();
}
Usage example:
sessionDate_to_printDate("2011-01-04");
should yield "Tues, Jan 4"
(in the PST timezone)
Upvotes: 1
Reputation:
have a look at http://phpjs.org/functions/date:380
by using this function you can display date in any format u like
Upvotes: 1