javascript - Common FormatDate function for different date formats -
am formatting date format in javascript below code
function changedateformat(date) { var fromjson = new date(parseint(date.replace(/(^.*\()|([+-].*$)/g, ''))); return fromjson.getmonth() + 1 + "/" + fromjson.getdate() + "/" + fromjson.getfullyear() + " " + fromjson.gethours() + ":" + fromjson.getminutes(); } i have 2 scenarios call function 2 diferent parameters
if date = "/date(1374145967638)/" getting correct o/p if date = "7/18/2013 4:28:52 pm" getting jan 01 1970 is there way can write common function in javascript/jquery handle both dates ?
am looking option without jquery plugins.
thanks
i think can first create javascript date object date string format in ever way want.
ex:
var date = new date("7/18/2013 4:28:52 pm"); then can use different date class methods , format string manually.
Comments
Post a Comment