javascript String to Get Hours and Minutes

javascript String to Get Hours and Minutes

In this Post We Will Explain About is javascript String to Get Hours and Minutes With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to javascript get hours and Minutes in 12 hour format Example

In this post we will show you Best way to implement convert hours to minutes in javascript, hear for javascript getminutes two digitswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Simple javascript Get Hours and Minutes Example

In this Example to Learn, String To get Hours and Minutes specific split to array convert. and then two difference hours to get particuler same day and validation per day select duration using javascript.

Make a HTML file and define markup


Example 1 : JavaScript Get Hours and Minutes using String


Example 2: JavaScript Get Hours and Minutes using String


Make a js file and define scripting

var html= "10 hour and 10 minute";
var mini =  html.substr(html.length - 10);
var number = parseInt(html.match(/-*[0-9]+/));
var mini = parseInt(mini.match(/-*[0-9]+/));

if(html.includes("and"))
{
	 document.getElementById('number').innerHTML="First hours: "+number;
   document.getElementById('minute').innerHTML="First minutes: "+mini;
}
else if(html.includes("hour"))
{
	document.getElementById('number').innerHTMLinnerHTML="First hours: "+number;
}
else if(html.includes("minute"))
{
	 document.getElementById('minute').innerHTML="First minutes: "+mini;
}

var time="18:00";
var timeArray = time.split(" ");
timeArray = timeArray[0].split(":");

var get_hour = parseInt(timeArray[0]);
var get_mini = parseInt(timeArray[1]);

document.getElementById('get_hour').innerHTML="Second get_hour: "+get_hour;
document.getElementById('get_mini').innerHTML="Second get_mini: "+get_mini;

var total_hours_get = get_hour+number;
if(total_hours_get <= 24)
{
	alert(total_hours_get);
}
else
{
 alert("false");
}

Example

I hope you have Got What is convert hours to minutes in javascript And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment