String string = "January 2, 2010";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM d, yyyy", Locale.ENGLISH);
LocalDate date = LocalDate.parse(string, formatter);
System.out.println(date); // 2010-01-02
var mydate = new Date('18/07/2022 11:09');
console.log(mydate.toDateString());
Run code snippetHide results
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;
}
}
Code Example |
---|
Csharp :: c# switch statement |
Html :: html grundgerüst |
Html :: lodash cdn |
Html :: qs cdn |
Html :: html empty character |
Html :: link css to html |
Html :: html disable editing textbox |
Html :: how to open link in new tab |
Html :: file input only images |
Html :: center text v-card |
Html :: call link html |
Html :: autoredirect html |
Html :: python jupyter markdown color |
Html :: how to change the preview image of a website |
Html :: make element disappear on smaller screens in bootstrap |
Html :: adding a favicon in html |
Html :: bootstrap large modal |
Html :: gender selection in html |
Html :: how to change the logo in the title of a webpage |
Html :: javascript generate pdf from div content jquery |
Html :: html option disabled |
Html :: tailwind css textarea |
Html :: html textarea |
Html :: django html checkbox if condition chexked |
Html :: html indice |
Html :: add fav icon to website |
Html :: video tag thumbnail |
Html :: html template |
Html :: contenteditable onchange |
Html :: increase video speed html5 |