Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

date string to date

	function stringToDate(_date,_format,_delimiter)
	{
		  if(_date != ''){
			  var formatLowerCase=_format.toLowerCase();
			  var formatItems=formatLowerCase.split(_delimiter);
			  var dateItems=_date.split(_delimiter);
			  var monthIndex=formatItems.indexOf("mm");
			  var dayIndex=formatItems.indexOf("dd");
			  var yearIndex=formatItems.indexOf("yyyy");
			  var month=parseInt(dateItems[monthIndex]);
			  month-=1;
			  var formattedDate = new Date(dateItems[yearIndex],month,dateItems[dayIndex]);
			  if(formattedDate == 'Invalid Date') formattedDate = undefined;
			  return formattedDate;
		  }else{
			  return undefined;
		  }	 		  
	}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #date #string #date
ADD COMMENT
Topic
Name
1+2 =