angularjs - How do I format start and end dates into custom format in Javascript? -


i have event has start date , end date follows:

var startdate = '10/9/2014 10:00:00 am' var enddate = '10/10/2014 5:00:00 pm' 

so event starts thursday , ends on friday

i display in following format

thursday & friday oct 9-10

and if single day

thursday oct 9th

and longer 2 days

thursday - sunday oct 9 - 12

i think momentjs might way go doing have not used yet , thought post question while try work out on own , see guys suggest.

unfortunately, there's no javascript date constructor allows pass in culture information uses localized date formats. best bet use constructor takes year, month, , day separately:

var parts = datestring.split('/'); var date = new date(parseint(parts[2], 10),                  parseint(parts[1], 10),                  parseint(parts[0], 10)); 

Comments

Popular posts from this blog

c# - HttpResponseMessage System.InvalidOperationException -

sql - Postgresql error: "failed to find conversion function from unknown to text" -