Showing posts with label Convert Date. Show all posts
Showing posts with label Convert Date. Show all posts

Thursday, 29 June 2017

Parse date from string to any date format

Parsing date from string  to cultural format



string timeFrameFromDate=date;

 lstItem["FromDate"] = DateTime.ParseExact(timeFrameFromDate, "dd/M/yyyy", CultureInfo.InvariantCulture);

Date Format Output will be  like this      31/12/2017



And Use below code to convert date in different format

function getFormattedDate(formatedDate) {
    var year = formatedDate.getFullYear();
    var month = (1 + formatedDate.getMonth()).toString();
    month = month.length > 1 ? month : '0' + month;
    var day = formatedDate.getDate().toString();
    day = day.length > 1 ? day : '0' + day;
    return day + '/' + month + '/' + year;

}