javascript - Date.parse(2/4/2011 9:34:48 AM) -


my input variable (ticket.creationdate) ,

2/4/2011 9:34:48 (it vary of course)

ideally pass in variable as-is , different results unknowndatefunc(ticket.datecreation) \ outputs= friday, february 4, 2011 unknowntimefunc(ticket.datecreation) \ outputs= 9:34 am

meddling date.parse() , .todatestring() , can't figure out.

resolved : using steve levithan method

var datevar = dateformat(ticketlist.tickets[ticket].creationdate.split(" ", 1), "fulldate");  // without .split(" ",1) displayed "thu, feb 24, 2011 00:00" don't know why var timevar = dateformat(ticketlist.tickets[ticket].creationdate, "shorttime"); 

i suggest combination of 2 different date libraries aware of.

the first, parsing date string, datejs. can find @ http://www.datejs.com/. example parses library fine (once include appropriate quote marks)

// results in date object tostring is:   //    fri feb 04 2011 09:34:48 gmt-0600 (central standard time) date.parse('2/4/2011 9:34:48 am') 

the other library creating nicely formatted string values based on date object. can found @ http://blog.stevenlevithan.com/archives/date-time-format. example, page:

// saturday, june 9th, 2007, 5:46:21 pm var = new date(); dateformat(now, "dddd, mmmm ds, yyyy, h:mm:ss tt"); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -